Service object to handle services on a system-level

The Service object now offers handling services on a system level,
and gathering information whether it's enabled or running.
New methods: enable, disable, is_enabled, is_running;

For this it needs the correct (system-level) service name.
All of the methods can be overridden/customized.

This changes all modules to the new Service object and deletes
action scripts that are not required anymore.
This commit is contained in:
fonfon authored and James Valleroy committed 2016-05-11 18:19:27 -04:00
1 parent 9fe49f881f
commit a9528c56d9
30 files changed
+243 -629

No files matched your search

+10 -8
View File
@@ -20,6 +20,7 @@ Plinth module to configure Tiny Tiny RSS.
"""
from django.utils.translation import ugettext_lazy as _
from functools import partial
from plinth import actions
from plinth import action_utils
@@ -44,6 +45,8 @@ description = [
service = None
managed_services = ['tt-rss']
def init():
"""Intialize the module."""
@@ -52,8 +55,8 @@ def init():
global service
service = service_module.Service(
'tt-rss', title, ['http', 'https'], is_external=True,
enabled=is_enabled())
managed_services[0], title, ports=['http', 'https'], is_external=True,
is_enabled=is_enabled, enable=_enable, disable=_disable)
def setup(helper, old_version=None):
@@ -67,7 +70,7 @@ def setup(helper, old_version=None):
def get_status():
"""Get the current settings."""
return {'enabled': is_enabled(),
'is_running': is_running()}
'is_running': service.is_running()}
def is_enabled():
@@ -76,11 +79,6 @@ def is_enabled():
action_utils.webserver_is_enabled('tt-rss-plinth'))
def is_running():
"""Return whether the service is running."""
return action_utils.service_is_running('tt-rss')
def enable(should_enable):
"""Enable/disable the module."""
sub_command = 'enable' if should_enable else 'disable'
@@ -96,3 +94,7 @@ def diagnose():
'https://{host}/tt-rss', extra_options=['--no-check-certificate']))
return results
_enable = partial(enable, True)
_disable = partial(enable, False)