Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Side by Side Diff: scripts/slave/recipe_modules/crrev/resources/crrev_client.py

Issue 1796993002: Fix crrev and add test coverage for the main function. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/crrev/resources/crrev_client_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright 2016 The Chromium Authors. All rights reserved. 2 # Copyright 2016 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """A simple client for the crrev.com API. 6 """A simple client for the crrev.com API.
7 7
8 API Explorer page: https://goo.gl/5ThLDm 8 API Explorer page: https://goo.gl/5ThLDm
9 9
10 Example usage: 10 Example usage:
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 if attempt >= attempts: 54 if attempt >= attempts:
55 raise 55 raise
56 logging.exception('Failed to request from crrev: %s', e) 56 logging.exception('Failed to request from crrev: %s', e)
57 57
58 logging.info('Sleeping %d seconds before retry (%d/%d).', 58 logging.info('Sleeping %d seconds before retry (%d/%d).',
59 retry_delay_seconds, attempt, attempts) 59 retry_delay_seconds, attempt, attempts)
60 time.sleep(retry_delay_seconds) 60 time.sleep(retry_delay_seconds)
61 retry_delay_seconds *= 2 61 retry_delay_seconds *= 2
62 62
63 63
64 def main(): 64 def main(args):
65 parser = argparse.ArgumentParser() 65 parser = argparse.ArgumentParser()
66 parser.add_argument('path', help='Path + query to add onto the base URL.') 66 parser.add_argument('path', help='Path + query to add onto the base URL.')
67 parser.add_argument('--params-file', help='Request parameter JSON file.') 67 parser.add_argument('--params-file', help='Request parameter JSON file.')
68 parser.add_argument('--attempts', default=1, help='Number of times to retry.') 68 parser.add_argument('--attempts', default=1, help='Number of times to retry.')
69 args = parser.parse_args() 69 args = parser.parse_args(args)
70 params = {} 70 params = {}
71 if args.params_file: 71 if args.params_file:
72 params = json.lad(args.params_file) 72 params = json.load(open(args.params_file))
73 print json.dumps(crrev_get(args.path, params, args.attempts), indent=2) 73 return json.dumps(crrev_get(args.path, params, args.attempts), indent=2)
74 74
75 75
76 if __name__ == '__main__': 76 if __name__ == '__main__':
77 main() 77 print main(sys.argv[1:])
OLDNEW
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/crrev/resources/crrev_client_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698