From b72021782e9b57a1fd1c7a13356ab47526f5707c Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 2 Oct 2019 23:28:19 -0700 Subject: [PATCH] deluge: Support deluge 2 by starting it properly deluge-web 1.x runs in the foreground by default and provides an option -f to fork in the background where as deluge-web 2.x by default forks into the background and provides option --do-no-daemonize for running in foreground. Update systemd service to ensure that option is passed appropriately based on the version of daemon running. Update functional tests to accommodate UI changes in deluge-web 2.x. Closes: #1652. Tests: - Install deluge 1.x by having testing in apt sources.list. Ensure that the daemon is working. Run functional tests. - Upgrade deluge to 2.x by changing the sources.list and upgrading. Ensure that daemon is working after disable/enable. Run functional tests. - Install deluge 2.x by having unstable in apt sources.list. Ensure that daemon is working. Run functional tests. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- actions/deluge | 9 ++++----- functional_tests/support/site.py | 32 ++++++++++++++++++------------- plinth/modules/deluge/__init__.py | 4 ++-- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/actions/deluge b/actions/deluge index b282dc425..3b3ab122d 100755 --- a/actions/deluge +++ b/actions/deluge @@ -37,7 +37,7 @@ Documentation=man:deluge-web(1) After=network.target [Service] -ExecStart=/usr/bin/deluge-web --base=deluge +ExecStart=bash -c "/usr/bin/deluge-web --base=deluge $(/usr/bin/deluge-web --version | grep deluge-web | cut -f2 -d' ' | grep -q '^1.' && echo '' || echo '--do-not-daemonize')" Restart=on-failure User=debian-deluged Group=debian-deluged @@ -60,11 +60,10 @@ def parse_arguments(): def subcommand_setup(_): """Perform initial setup for deluge-web.""" - if not os.path.isfile(SYSTEMD_SERVICE_PATH): - with open(SYSTEMD_SERVICE_PATH, 'w') as file_handle: - file_handle.write(SYSTEMD_SERVICE) + with open(SYSTEMD_SERVICE_PATH, 'w') as file_handle: + file_handle.write(SYSTEMD_SERVICE) - subprocess.check_call(['systemctl', 'daemon-reload']) + subprocess.check_call(['systemctl', 'daemon-reload']) def main(): diff --git a/functional_tests/support/site.py b/functional_tests/support/site.py index bfd831f96..399853f9b 100644 --- a/functional_tests/support/site.py +++ b/functional_tests/support/site.py @@ -350,7 +350,8 @@ def _deluge_ensure_daemon_started(browser): """Start the deluge daemon if it is not started.""" _deluge_open_connection_manager(browser) - browser.find_by_xpath('//em[text()="127.0.0.1:58846"]').first.click() + browser.find_by_xpath( + '//em[contains(text(),"127.0.0.1:58846")]').first.click() if browser.is_element_present_by_xpath('//button[text()="Stop Daemon"]'): return @@ -433,22 +434,27 @@ def deluge_upload_sample_torrent(browser): eventually( lambda: _deluge_get_active_window_title(browser) == 'Add Torrents') - browser.find_by_css('button.x-deluge-add-file').first.click() - - # Add from file window appears - eventually( - lambda: _deluge_get_active_window_title(browser) == 'Add from File') - - # Attach file file_path = os.path.join( os.path.dirname(__file__), '..', 'data', 'sample.torrent') - browser.attach_file('file', file_path) - # Click Add - _deluge_click_active_window_button(browser, 'Add') + if browser.find_by_id('fileUploadForm'): # deluge-web 2.x + browser.attach_file('file', file_path) + else: # deluge-web 1.x + browser.find_by_css('button.x-deluge-add-file').first.click() - eventually( - lambda: _deluge_get_active_window_title(browser) == 'Add Torrents') + # Add from file window appears + eventually( + lambda: _deluge_get_active_window_title(browser) == 'Add from File' + ) + + # Attach file + browser.attach_file('file', file_path) + + # Click Add + _deluge_click_active_window_button(browser, 'Add') + + eventually( + lambda: _deluge_get_active_window_title(browser) == 'Add Torrents') # Click Add time.sleep(1) diff --git a/plinth/modules/deluge/__init__.py b/plinth/modules/deluge/__init__.py index ad0cc049b..797d51b6a 100644 --- a/plinth/modules/deluge/__init__.py +++ b/plinth/modules/deluge/__init__.py @@ -28,9 +28,9 @@ from plinth.modules.apache.components import Webserver from plinth.modules.firewall.components import Firewall from plinth.modules.users import register_group -from .manifest import backup, clients # noqa, pylint: disable=unused-import +from .manifest import backup, clients # noqa, pylint: disable=unused-import -version = 2 +version = 3 managed_services = ['deluge-web']