Changeset - 8dae2a288339
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 12 years ago 2013-05-22 23:36:59
marcin@python-works.com
API cli should prefer to display errors instead of responses
1 file changed with 5 insertions and 1 deletions:
0 comments (0 inline, 0 general)
rhodecode/bin/rhodecode_api.py
Show inline comments
 
@@ -96,22 +96,26 @@ def main(argv=None):
 
    # if we don't have method here it's an error
 
    if not method:
 
        parser.error('Please specify method name')
 

	
 
    try:
 
        margs = dict(map(lambda s: s.split(':', 1), other))
 
    except Exception:
 
        sys.stderr.write('Error parsing arguments \n')
 
        sys.exit()
 
    if args.format == FORMAT_PRETTY:
 
        print 'Calling method %s => %s' % (method, apihost)
 

	
 
    json_data = api_call(apikey, apihost, method, **margs)['result']
 
    json_resp = api_call(apikey, apihost, method, **margs)
 
    if json_resp['error']:
 
        json_data = json_resp['error']
 
    else:
 
        json_data = json_resp['result']
 
    if args.format == FORMAT_JSON:
 
        print json.dumps(json_data)
 
    elif args.format == FORMAT_PRETTY:
 
        print 'Server response \n%s' % (
 
                json.dumps(json_data, indent=4, sort_keys=True))
 
    return 0
 

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