Did I find the right examples for you? yes no

All Samples(5)  |  Call(4)  |  Derive(0)  |  Import(1)
Warning this only works with a very simple setting format: NAME = value 

        def update_settings(monkey_patch=None, **options):
    """ Warning this only works with a very simple setting format: NAME = value """
    from django.conf import settings
    for name, value in options.iteritems():
        if getattr(settings, name, None) != value:
            settings_file = os.path.join(get_project_root(), 'settings.py')
            context = {
                'name': name,
                'value': value if not isinstance(value, basestring) else "'%s'" % value,
                'settings': settings_file,
            }
            if run("grep '^%(name)s *=' %(settings)s" % context, err_codes=[0,1]):
                # Update existing settings_file
                run("sed -i \"s#%(name)s *=.*#%(name)s = %(value)s#\" %(settings)s" % context)
            else:
                run("echo \"%(name)s = %(value)s\" >> %(settings)s" % context)
            # Monkeypatch controller settings to make available the change globally
            if monkey_patch is not None:
                module = import_module(monkey_patch)
                setattr(module, name, value)
        


src/c/o/confine-controller-0.10.5/controller/apps/mgmtnetworks/tinc/management/commands/setuptincd.py   confine-controller(Download)
 
from controller import settings
from controller.utils import update_settings
from controller.utils.system import check_root, run, get_default_celeryd_username
from nodes.models import Server
 
        if mgmt_prefix != settings.MGMT_IPV6_PREFIX:
            update_settings(MGMT_IPV6_PREFIX=mgmt_prefix,
                            monkey_patch='controller.settings')
        if tinc_port != TINC_PORT_DFLT:
            update_settings(TINC_PORT_DFLT=tinc_port)
        if tinc_net_name != TINC_NET_NAME:
            update_settings(TINC_NET_NAME=tinc_net_name)
                    'You may want to use --nohup option, so sudo will not be a requirement')
        else:
            update_settings(TINC_TINCD_SEND_HUP=False)
        self.stdout.write('Tincd server successfully created and configured.')