mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
deluge: Remove get-enabled from actions
- Use webserver action utilites. - Move status getting to module __init__.py so that it can be turned into an API in future for further simplificaiton. - Apply this to other modules too in future commits.
This commit is contained in:
1 parent
ac19238e91
commit
7cf47bbcb2
3 files changed
+18
-43
No files matched your search
@@ -22,6 +22,7 @@ Plinth module to configure a Deluge web client.
|
||||
from gettext import gettext as _
|
||||
|
||||
from plinth import actions
|
||||
from plinth import action_utils
|
||||
from plinth import cfg
|
||||
from plinth import service as service_module
|
||||
|
||||
@@ -37,10 +38,18 @@ def init():
|
||||
menu.add_urlname(_('BitTorrent (Deluge)'), 'glyphicon-magnet',
|
||||
'deluge:index', 60)
|
||||
|
||||
output = actions.run('deluge', ['get-enabled'])
|
||||
enabled = (output.strip() == 'yes')
|
||||
|
||||
global service
|
||||
service = service_module.Service(
|
||||
'deluge', _('Deluge BitTorrent'), ['http', 'https'],
|
||||
is_external=True, enabled=enabled)
|
||||
is_external=True, enabled=is_enabled())
|
||||
|
||||
|
||||
def is_enabled():
|
||||
"""Return whether the module is enabled."""
|
||||
return (action_utils.webserver_is_enabled('deluge-plinth') and
|
||||
action_utils.service_is_enabled('deluge-web'))
|
||||
|
||||
|
||||
def is_running():
|
||||
"""Return whether the service is running."""
|
||||
return action_utils.service_is_running('deluge-web')
|
||||
@@ -25,7 +25,6 @@ from gettext import gettext as _
|
||||
|
||||
from .forms import DelugeForm
|
||||
from plinth import actions
|
||||
from plinth import action_utils
|
||||
from plinth import package
|
||||
from plinth.modules import deluge
|
||||
|
||||
@@ -55,11 +54,8 @@ def index(request):
|
||||
|
||||
def get_status():
|
||||
"""Get the current settings."""
|
||||
output = actions.run('deluge', ['get-enabled'])
|
||||
enabled = (output.strip() == 'yes')
|
||||
|
||||
status = {'enabled': enabled,
|
||||
'is_running': action_utils.service_is_running('deluge-web')}
|
||||
status = {'enabled': deluge.is_enabled(),
|
||||
'is_running': deluge.is_running()}
|
||||
|
||||
return status
|
||||
|
||||
|
||||
Reference in new issue
Block a user