Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """"Serves as a client for selected APIs in Buildbucket.""" | 5 """"Serves as a client for selected APIs in Buildbucket.""" |
| 6 | 6 |
| 7 import collections | 7 import collections |
| 8 import json | 8 import json |
| 9 import logging | 9 import logging |
| 10 | 10 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 | 70 |
| 71 This corresponds to the Build in Buildbucket. | 71 This corresponds to the Build in Buildbucket. |
| 72 """ | 72 """ |
| 73 | 73 |
| 74 # Build statuses. | 74 # Build statuses. |
| 75 SCHEDULED = 'SCHEDULED' | 75 SCHEDULED = 'SCHEDULED' |
| 76 STARTED = 'STARTED' | 76 STARTED = 'STARTED' |
| 77 COMPLETED = 'COMPLETED' | 77 COMPLETED = 'COMPLETED' |
| 78 | 78 |
| 79 def __init__(self, raw_json_data): | 79 def __init__(self, raw_json_data): |
| 80 self.response = raw_json_data | |
| 80 self.id = raw_json_data.get('id') | 81 self.id = raw_json_data.get('id') |
| 81 self.url = raw_json_data.get('url') | 82 self.url = raw_json_data.get('url') |
| 82 self.status = raw_json_data.get('status') | 83 self.status = raw_json_data.get('status') |
| 83 self.request_time = raw_json_data.get('created_ts') | 84 self.request_time = raw_json_data.get('created_ts') |
| 84 self.updated_time = raw_json_data.get('updated_ts') | 85 self.updated_time = raw_json_data.get('updated_ts') |
| 85 self.end_time = raw_json_data.get('completed_ts') | 86 self.end_time = raw_json_data.get('completed_ts') |
| 87 self.buildbucket_response = raw_json_data | |
|
stgao
2016/04/22 00:37:53
Why we save two copies of the same data?
lijeffrey
2016/04/22 00:50:53
Oops, removed.
| |
| 86 result_details_json = json.loads( | 88 result_details_json = json.loads( |
| 87 raw_json_data.get('result_details_json', '{}')) or {} | 89 raw_json_data.get('result_details_json', '{}')) or {} |
| 88 self.report = result_details_json.get('properties', {}).get('report', {}) | 90 self.report = result_details_json.get('properties', {}).get('report', {}) |
| 89 | 91 |
| 90 | 92 |
| 91 class BuildbucketError(object): | 93 class BuildbucketError(object): |
| 92 """Represents an error returned by Buildbucket.""" | 94 """Represents an error returned by Buildbucket.""" |
| 93 | 95 |
| 94 # Error reasons. | 96 # Error reasons. |
| 95 BUILD_NOT_FOUND = 'BUILD_NOT_FOUND' | 97 BUILD_NOT_FOUND = 'BUILD_NOT_FOUND' |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 else: | 185 else: |
| 184 error_content = { | 186 error_content = { |
| 185 'error': { | 187 'error': { |
| 186 'reason': status_code, | 188 'reason': status_code, |
| 187 'message': content | 189 'message': content |
| 188 } | 190 } |
| 189 } | 191 } |
| 190 json_results.append(error_content) | 192 json_results.append(error_content) |
| 191 | 193 |
| 192 return _ConvertFuturesToResults(json_results) | 194 return _ConvertFuturesToResults(json_results) |
| OLD | NEW |