Exemplo n.º 1
0
def cmd_set(opts, args, overDict):
    from main import settings
    from interface import api
    name = args[1].lower()
    if name in ['list', 'ls', 'all', 'show', 'print', ]:
        settings.init()
        sort = True if (len(args) > 2 and args[2] in ['sort', 'sorted', ]) else False
        result = api.config_list(sort)
        for i in xrange(len(result['result'])):
            result['result'][i]['value'] = result['result'][i]['value'][:60]
        tpl = jsontemplate.Template(templ.TPL_OPTIONS_LIST_KEY_TYPE_VALUE)
        print_template(result, tpl)
        return 0
    path = '' if len(args) < 2 else args[1]
    path = option_name_to_path(name, path)
    if path != '':
        settings.init()
        if len(args) > 2:
            value = ' '.join(args[2:])
            result = api.config_set(path, unicode(value))
        else:
            result = api.config_get(path)
        tpl = jsontemplate.Template(templ.TPL_OPTION_MODIFIED)
        print_template(result, tpl)
        return 0
    return 2
Exemplo n.º 2
0
 def jsonrpc_config_get(self, key):
     return api.config_get(key)
Exemplo n.º 3
0
 def config_get_v1(self, request):
     # cgi.escape(dict({} or request.args).get('key', [''])[0]),)
     return api.config_get(key=_request_arg(request, 'key', mandatory=True))
Exemplo n.º 4
0
 def config_get_l1_v1(self, request, key):
     return api.config_get(key=key)
Exemplo n.º 5
0
 def config_get_l2_v1(self, request, key1, key2):
     return api.config_get(key=(key1 + '/' + key2))
Exemplo n.º 6
0
 def config_get_l3_v1(self, request, key1, key2, key3):
     return api.config_get(key=(key1 + '/' + key2 + '/' + key3))