| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 at | 4 # found in the LICENSE file at |
| 5 # http://src.chromium.org/viewvc/chrome/trunk/src/LICENSE | 5 # http://src.chromium.org/viewvc/chrome/trunk/src/LICENSE |
| 6 # This file is NOT under GPL. | 6 # This file is NOT under GPL. |
| 7 | 7 |
| 8 """Queries buildbot through the json interface. | 8 """Queries buildbot through the json interface. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 if remaining > datetime.timedelta(seconds=0): | 939 if remaining > datetime.timedelta(seconds=0): |
| 940 logging.debug('Sleeping for %ss' % remaining) | 940 logging.debug('Sleeping for %ss' % remaining) |
| 941 time.sleep(remaining.seconds) | 941 time.sleep(remaining.seconds) |
| 942 self.last_fetch = datetime.datetime.utcnow() | 942 self.last_fetch = datetime.datetime.utcnow() |
| 943 url = '%s/json/%s' % (self.url, suburl) | 943 url = '%s/json/%s' % (self.url, suburl) |
| 944 if '?' in url: | 944 if '?' in url: |
| 945 url += '&filter=1' | 945 url += '&filter=1' |
| 946 else: | 946 else: |
| 947 url += '?filter=1' | 947 url += '?filter=1' |
| 948 logging.debug('read(%s)' % suburl) | 948 logging.debug('read(%s)' % suburl) |
| 949 channel = urllib.urlopen(url) | 949 try: |
| 950 data = channel.read() | 950 channel = urllib.urlopen(url) |
| 951 data = channel.read() |
| 952 except IOError as e: |
| 953 logging.warning('caught %s while fetching "%s"; re-throwing' % ( |
| 954 str(e), url)) |
| 955 raise |
| 951 try: | 956 try: |
| 952 return json.loads(data) | 957 return json.loads(data) |
| 953 except ValueError: | 958 except ValueError: |
| 954 if channel.getcode() >= 400: | 959 if channel.getcode() >= 400: |
| 955 # Convert it into an HTTPError for easier processing. | 960 # Convert it into an HTTPError for easier processing. |
| 956 raise urllib2.HTTPError( | 961 raise urllib2.HTTPError( |
| 957 url, channel.getcode(), '%s:\n%s' % (url, data), channel.headers, | 962 url, channel.getcode(), '%s:\n%s' % (url, data), channel.headers, |
| 958 None) | 963 None) |
| 959 raise | 964 raise |
| 960 | 965 |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1441 gen_usage(parser, args[0]) | 1446 gen_usage(parser, args[0]) |
| 1442 return command(parser, args[1:]) | 1447 return command(parser, args[1:]) |
| 1443 | 1448 |
| 1444 # Not a known command. Default to help. | 1449 # Not a known command. Default to help. |
| 1445 gen_usage(parser, 'help') | 1450 gen_usage(parser, 'help') |
| 1446 return CMDhelp(parser, args) | 1451 return CMDhelp(parser, args) |
| 1447 | 1452 |
| 1448 | 1453 |
| 1449 if __name__ == '__main__': | 1454 if __name__ == '__main__': |
| 1450 sys.exit(main()) | 1455 sys.exit(main()) |
| OLD | NEW |