Edit preferences in /usr/cdrouter-data/etc/config.yml.

        :param resource: :class:`system.Preferences <system.Preferences>` object
        :return: :class:`system.Preferences <system.Preferences>` object
        :rtype: system.Preferences
195880
def edit_preferences(self, resource):
        
        schema = PreferencesSchema()
        json = self.service.encode(schema, resource)

        schema = PreferencesSchema()
        resp = self.service.patch(self.base+'preferences/', json=json)
        return self.service.decode(schema, resp)
892279
function (rootdir, platform) {
        var configXml = lib.getConfigXml(rootdir);

        //init common config.xml prefs if we haven't already
        var preferencesData = {
            common: configXml.findall('preference')
        };

        var prefs = preferencesData.common || [];
        if (platform) {
            if (!preferencesData[platform]) {
                preferencesData[platform] = configXml.findall('platform[@name=\'' + platform + '\']/preference');
            }
            prefs = prefs.concat(preferencesData[platform]);
        }

        return prefs;
    }
765392
def update_defaults(self, ext_config):
        
        for setting in dir(ext_config):
            if setting.isupper() and not hasattr(self, setting):
                setattr(self, setting, getattr(ext_config, setting))
269486
def _configure_manager(self):
        
        self._manager = ContainerManager(self, resource_class=Container,
                response_key="", uri_base="")
1212815
void editListConfiguration(CmsResource resource) {

        try {
            CmsObject cms = A_CmsUI.getCmsObject();
            String editState;
            if (resource == null) {
                editState = CmsEditor.getEditStateForNew(
                    cms,
                    OpenCms.getResourceManager().getResourceType(RES_TYPE_LIST_CONFIG),
                    "/",
                    null,
                    false,
                    UI.getCurrent().getPage().getLocation().toString());
            } else {
                editState = CmsEditor.getEditState(
                    resource.getStructureId(),
                    false,
                    UI.getCurrent().getPage().getLocation().toString());
            }
            View view = CmsAppWorkplaceUi.get().getCurrentView();
            if (view instanceof CmsAppView) {
                ((CmsAppView)view).setCacheStatus(CacheStatus.cacheOnce);
            }
            CmsAppWorkplaceUi.get().showApp(
                OpenCms.getWorkplaceAppManager().getAppConfiguration(CmsEditorConfiguration.APP_ID),
                editState);

        } catch (CmsLoaderException e) {
            CmsErrorDialog.showErrorDialog(e);
        }
    }
89882
def configure(ctx, helper, edit):
    '''
    
    '''

    ctx.obj.config = ConfigFile(ctx.obj.config_file)

    if edit:
        ctx.obj.config.edit_config_file()
        return

    if os.path.isfile(ctx.obj.config.config_file):
        ctx.obj.config.read_config()

    if ctx.obj.profile is None:
        ctx.obj.profile = ctx.obj.config.default_profile

    args, kwargs = _parse_args_and_kwargs(ctx.args)
    assert len(args) == 0, 'Unrecognized arguments: "{}"'.format(args)

    if ctx.obj.profile not in ctx.obj.config.config['profiles']:
        ctx.obj.config.config['profiles'][ctx.obj.profile] = {
            'api': {'user_config': {}}, 'manager': {}, 'authorities': {}}

    profile_config = ctx.obj.config.config['profiles'][ctx.obj.profile]
    profile_config['api']['user_config'].update(kwargs)

    ctx.obj.config.write_config(ctx.obj.config_file)

    _generate_api(ctx)

    if ctx.obj.api.manager is not None:
        check_requirements(
            to_populate=profile_config['api']['user_config'],
            prompts=ctx.obj.api.manager.required_user_config,
            helper=helper)

    ctx.obj.config.write_config(ctx.obj.config_file)
214587
def do_set_port_config(self, line):
        

        def f(p, args):
            try:
                target, port, key, value = args
            except:
                print("argument error")
                print(args)
                return

            # get switch id
            o = p.get()
            capable_switch_id = o.id

            try:
                capable_switch = ofc.OFCapableSwitchType(
                    id=capable_switch_id,
                    resources=ofc.OFCapableSwitchResourcesType(
                        port=[
                            ofc.OFPortType(
                                resource_id=port,
                                configuration=ofc.OFPortConfigurationType(
                                    **{key: value}))
                        ]
                    )
                )
            except TypeError:
                print("argument error")
                return
            try:
                p.edit_config(target, capable_switch)
            except Exception as e:
                print(e)

        self._request(line, f)
86838
def refresh_context(self):
        
        User = self.model('res.user')

        self.context = User.get_preferences(True)
        return self.context
1347109
def edit_resource(self, transaction, path):
        
        resource_node = self._parent.root[path]
        transaction.resource = resource_node
        # If-Match
        if transaction.request.if_match:
            if None not in transaction.request.if_match and str(transaction.resource.etag) \
                    not in transaction.request.if_match:
                transaction.response.code = defines.Codes.PRECONDITION_FAILED.number
                return transaction

        method = getattr(resource_node, "render_POST", None)
        try:
            resource = method(request=transaction.request)
        except NotImplementedError:
            try:
                method = getattr(resource_node, "render_POST_advanced", None)
                ret = method(request=transaction.request, response=transaction.response)
                if isinstance(ret, tuple) and len(ret) == 2 and isinstance(ret[1], Response) \
                        and isinstance(ret[0], Resource):
                    # Advanced handler
                    resource, response = ret
                    resource.changed = True
                    resource.observe_count += 1
                    transaction.resource = resource
                    transaction.response = response
                    if transaction.response.code is None:
                        transaction.response.code = defines.Codes.CREATED.number
                    return transaction
                elif isinstance(ret, tuple) and len(ret) == 3 and isinstance(ret[1], Response) \
                        and isinstance(ret[0], Resource):
                    # Advanced handler separate
                    resource, response, callback = ret
                    ret = self._handle_separate_advanced(transaction, callback)
                    if not isinstance(ret, tuple) or \
                            not (isinstance(ret[0], Resource) and isinstance(ret[1], Response)):  # pragma: no cover
                        transaction.response.code = defines.Codes.INTERNAL_SERVER_ERROR.number
                        return transaction
                    resource, response = ret
                    resource.changed = True
                    resource.observe_count += 1
                    transaction.resource = resource
                    transaction.response = response
                    if transaction.response.code is None:
                        transaction.response.code = defines.Codes.CREATED.number
                    return transaction
                else:
                    raise NotImplementedError
            except NotImplementedError:
                transaction.response.code = defines.Codes.METHOD_NOT_ALLOWED.number
                return transaction

        if isinstance(resource, Resource):
            pass
        elif isinstance(resource, tuple) and len(resource) == 2:
            resource, callback = resource
            resource = self._handle_separate(transaction, callback)
            if not isinstance(resource, Resource):  # pragma: no cover
                transaction.response.code = defines.Codes.INTERNAL_SERVER_ERROR.number
                return transaction
        else:  # pragma: no cover
            # Handle error
            transaction.response.code = defines.Codes.INTERNAL_SERVER_ERROR.number
            return transaction

        if resource.path is None:
            resource.path = path
        resource.observe_count = resource_node.observe_count

        if resource is resource_node:
            transaction.response.code = defines.Codes.CHANGED.number
        else:
            transaction.response.code = defines.Codes.CREATED.number
        resource.changed = True
        resource.observe_count += 1
        transaction.resource = resource

        assert(isinstance(resource, Resource))
        if resource.etag is not None:
            transaction.response.etag = resource.etag

        transaction.response.location_path = resource.path

        if resource.location_query is not None and len(resource.location_query) > 0:
            transaction.response.location_query = resource.location_query

        transaction.response.payload = None

        self._parent.root[resource.path] = resource

        return transaction
877174
def open_resource(self, resource, *mode):
        
        return self.open(self.resource_name(resource), *mode)
547070
def changelist_view(self, request, extra_context=None):
        
        model = self.model
        if model.objects.all().count() > 1:
            return super(PreferencesAdmin, self).changelist_view(request)
        else:
            obj = model.singleton.get()
            return redirect(
                reverse(
                    'admin:%s_%s_change' % (
                        model._meta.app_label, model._meta.model_name
                    ),
                    args=(obj.id,)
                )
            )
1348101
def set_preferences(self, **kwargs):
        
        json_data = "json={}".format(json.dumps(kwargs))
        headers = {'content-type': 'application/x-www-form-urlencoded'}
        return self._post('command/setPreferences', data=json_data,
                          headers=headers)
1097207
def _set_default_resource_names(self):
        
        self.ip_config_name = ''.join([
            self.running_instance_id, '-ip-config'
        ])
        self.nic_name = ''.join([self.running_instance_id, '-nic'])
        self.public_ip_name = ''.join([self.running_instance_id, '-public-ip'])
654401
def set(self, logicalId, resource):
        

        resource_dict = resource
        if isinstance(resource, SamResource):
            resource_dict = resource.to_dict()

        self.resources[logicalId] = resource_dict
1197766
def edit_resource(self, request):
        
        self.location_query = request.uri_query
        self.payload = (request.content_type, request.payload)
773017
def update_config_mode(self, prompt):  # pylint: disable=no-self-use
        """"""
        mode = 'global'
        if prompt:
            if 'config' in prompt:
                mode = 'config'
            elif 'admin' in prompt:
                mode = 'admin'

        self.log("Mode: {}".format(mode))
        return mode
614503
def update_config(self, config):
    
    path = self._path() + '/config'
    resp = self._get_resource_root().put(path, data = config_to_json(config))
    return json_to_config(resp)