Changeset - 02fc6ce0cd44
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 13 years ago 2012-06-25 23:08:06
marcin@python-works.com
don't make a api call after doing create_config
1 file changed with 3 insertions and 1 deletions:
0 comments (0 inline, 0 general)
rhodecode/bin/rhodecode_api.py
Show inline comments
 
@@ -133,25 +133,25 @@ def api_call(apikey, apihost, format, me
 
        :param random_id:
 
        :type random_id:
 
        """
 
        return {
 
            "id": random_id,
 
            "api_key": apikey,
 
            "method": method,
 
            "args": kw
 
        }
 

	
 
    if not method:
 
        raise Exception('please specify method name !')
 
    id_ = random.randrange(1, 200)
 
    id_ = random.randrange(1, 9999)
 
    req = urllib2.Request('%s/_admin/api' % apihost,
 
                      data=json.dumps(_build_data(id_)),
 
                      headers={'content-type': 'text/plain'})
 
    if format == FORMAT_PRETTY:
 
        sys.stdout.write('calling %s to %s \n' % (req.get_data(), apihost))
 
    ret = urllib2.urlopen(req)
 
    raw_json = ret.read()
 
    json_data = json.loads(raw_json)
 
    id_ret = json_data['id']
 
    _formatted_json = pprint.pformat(json_data)
 
    if id_ret == id_:
 
        if format == FORMAT_JSON:
 
@@ -212,19 +212,21 @@ def main(argv=None):
 
        sys.stdout.write('Create new config in %s\n' % CONFIG_NAME)
 

	
 
    if not conf:
 
        conf = RcConf(autoload=True)
 
        if not conf:
 
            if not api_credentials_given:
 
                parser.error('Could not find config file and missing '
 
                             '--apikey or --apihost in params')
 

	
 
    apikey = args.apikey or conf['apikey']
 
    host = args.apihost or conf['apihost']
 
    method = args.method
 
    if method == '_create_config':
 
        sys.exit()
 
    margs = dict(map(lambda s: s.split(':', 1), other))
 

	
 
    api_call(apikey, host, args.format, method, **margs)
 
    return 0
 

	
 
if __name__ == '__main__':
 
    sys.exit(main(sys.argv))
0 comments (0 inline, 0 general)