deluge: Further improvements to actions

- Perform disable even when the service is not running.

- Improve checking if deluge is enabled.
This commit is contained in:
Sunil Mohan Adapa 2015-06-26 18:55:11 +05:30
parent 2f56a516de
commit 0335ee9c32

View File

@ -26,8 +26,6 @@ import os
import subprocess
APACHE_CONF_ENABLED_PATH = '/etc/apache2/conf-enabled/deluge-plinth.conf'
SYSTEMD_SERVICE_PATH = '/etc/systemd/system/deluge-web.service'
SYSTEMD_SERVICE = '''
#
@ -74,10 +72,12 @@ def parse_arguments():
def subcommand_get_enabled(_):
"""Get whether deluge-web site is enabled."""
if os.path.isfile(APACHE_CONF_ENABLED_PATH) and \
os.path.isfile(SYSTEMD_SERVICE_PATH):
try:
subprocess.check_output(['a2query', '-c', 'deluge-plinth'],
stderr=subprocess.STDOUT)
subprocess.check_output(['systemctl', 'is-enabled', 'deluge-web'])
print('yes')
else:
except subprocess.CalledProcessError:
print('no')
@ -124,10 +124,11 @@ def disable():
try:
subprocess.check_output(['systemctl', 'stop', 'deluge-web'])
subprocess.check_output(['systemctl', 'disable', 'deluge-web'])
except subprocess.CalledProcessError:
pass
subprocess.check_output(['systemctl', 'disable', 'deluge-web'])
def setup():
"""Perform initial setup for deluge-web."""