config: Avoid sending domain_added signal for empty domain

- Fixes #1123

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Joseph Nuthalapati 2017-11-22 08:02:45 +05:30 committed by James Valleroy
parent 714db18b3f
commit bf1664aa9d
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 20 additions and 21 deletions

View File

@ -20,8 +20,8 @@ Configuration helper for Cockpit.
""" """
import argparse import argparse
import augeas
import augeas
from plinth import action_utils from plinth import action_utils
CONFIG_FILE = '/etc/cockpit/cockpit.conf' CONFIG_FILE = '/etc/cockpit/cockpit.conf'
@ -32,10 +32,10 @@ def parse_arguments():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command') subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
subparser = subparsers.add_parser( subparser = subparsers.add_parser('setup',
'setup', help='Setup Cockpit configuration') help='Setup Cockpit configuration')
subparser.add_argument( subparser.add_argument('domain_names', nargs='*',
'domain_names', nargs='*', help='Domain names to be allowed') help='Domain names to be allowed')
subparsers.add_parser('enable', help='Enable Cockpit') subparsers.add_parser('enable', help='Enable Cockpit')
subparsers.add_parser('disable', help='Disable Cockpit') subparsers.add_parser('disable', help='Disable Cockpit')
subparser = subparsers.add_parser( subparser = subparsers.add_parser(
@ -85,7 +85,7 @@ def subcommand_disable(_):
def _get_origin_domains(aug): def _get_origin_domains(aug):
"""Return the list of allowed origin domains.""" """Return the list of allowed origin domains."""
origins = aug.get('/files' + CONFIG_FILE + '/WebService/Origins') 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): def _set_origin_domains(aug, origins):

View File

@ -14,21 +14,19 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
""" """
Plinth module for basic system configuration 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 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 version = 1
@ -46,8 +44,8 @@ def get_domainname():
def init(): def init():
"""Initialize the module""" """Initialize the module"""
menu = main_menu.get('system') menu = main_menu.get('system')
menu.add_urlname(ugettext_lazy('Configure'), 'glyphicon-cog', menu.add_urlname(
'config:index') ugettext_lazy('Configure'), 'glyphicon-cog', 'config:index')
# Register domain with Name Services module. # Register domain with Name Services module.
domainname = get_domainname() domainname = get_domainname()
@ -62,7 +60,8 @@ def init():
else: else:
domainname_services = None domainname_services = None
domain_added.send_robust(sender='config', domain_type='domainname', if domainname:
name=domainname, domain_added.send_robust(sender='config', domain_type='domainname',
description=ugettext_lazy('Domain Name'), name=domainname,
services=domainname_services) description=ugettext_lazy('Domain Name'),
services=domainname_services)