diff --git a/actions/cockpit b/actions/cockpit index 5e2e79015..37da474e7 100755 --- a/actions/cockpit +++ b/actions/cockpit @@ -20,8 +20,8 @@ Configuration helper for Cockpit. """ import argparse -import augeas +import augeas from plinth import action_utils CONFIG_FILE = '/etc/cockpit/cockpit.conf' @@ -32,10 +32,10 @@ def parse_arguments(): parser = argparse.ArgumentParser() subparsers = parser.add_subparsers(dest='subcommand', help='Sub command') - subparser = subparsers.add_parser( - 'setup', help='Setup Cockpit configuration') - subparser.add_argument( - 'domain_names', nargs='*', help='Domain names to be allowed') + subparser = subparsers.add_parser('setup', + help='Setup Cockpit configuration') + subparser.add_argument('domain_names', nargs='*', + help='Domain names to be allowed') subparsers.add_parser('enable', help='Enable Cockpit') subparsers.add_parser('disable', help='Disable Cockpit') subparser = subparsers.add_parser( @@ -85,7 +85,7 @@ def subcommand_disable(_): def _get_origin_domains(aug): """Return the list of allowed origin domains.""" origins = aug.get('/files' + CONFIG_FILE + '/WebService/Origins') - return set(origins.split()) + return set(origins.split()) if origins else set() def _set_origin_domains(aug, origins): diff --git a/plinth/modules/config/__init__.py b/plinth/modules/config/__init__.py index 5736ee916..1ba9cc796 100644 --- a/plinth/modules/config/__init__.py +++ b/plinth/modules/config/__init__.py @@ -14,21 +14,19 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # - """ Plinth module for basic system configuration """ -from django.utils.translation import ugettext_lazy - -from plinth.menu import main_menu -from plinth.modules import firewall -from plinth import actions -from plinth.signals import domain_added -from plinth.modules.names import SERVICES - import socket +from django.utils.translation import ugettext_lazy + +from plinth import actions +from plinth.menu import main_menu +from plinth.modules import firewall +from plinth.modules.names import SERVICES +from plinth.signals import domain_added version = 1 @@ -46,8 +44,8 @@ def get_domainname(): def init(): """Initialize the module""" menu = main_menu.get('system') - menu.add_urlname(ugettext_lazy('Configure'), 'glyphicon-cog', - 'config:index') + menu.add_urlname( + ugettext_lazy('Configure'), 'glyphicon-cog', 'config:index') # Register domain with Name Services module. domainname = get_domainname() @@ -62,7 +60,8 @@ def init(): else: domainname_services = None - domain_added.send_robust(sender='config', domain_type='domainname', - name=domainname, - description=ugettext_lazy('Domain Name'), - services=domainname_services) + if domainname: + domain_added.send_robust(sender='config', domain_type='domainname', + name=domainname, + description=ugettext_lazy('Domain Name'), + services=domainname_services)