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 16 matching lines...) Expand all Loading... | |
| 27 name, while Findit uses shortened master name (tryserver.chromium.linux). | 27 name, while Findit uses shortened master name (tryserver.chromium.linux). |
| 28 """ | 28 """ |
| 29 prefix = 'master.' | 29 prefix = 'master.' |
| 30 if master_name.startswith(prefix): | 30 if master_name.startswith(prefix): |
| 31 return master_name | 31 return master_name |
| 32 return '%s%s' % (prefix, master_name) | 32 return '%s%s' % (prefix, master_name) |
| 33 | 33 |
| 34 | 34 |
| 35 class TryJob(collections.namedtuple( | 35 class TryJob(collections.namedtuple( |
| 36 'TryJobNamedTuple', | 36 'TryJobNamedTuple', |
| 37 ('master_name', 'builder_name', 'revision', 'properties', 'tags'))): | 37 ('master_name', 'builder_name', 'revision', 'properties', 'tags', |
| 38 'additional_parameters')) | |
|
stgao
2016/05/20 18:34:36
nit: "build_parameters" to be more clear and to ma
chanli
2016/05/20 20:52:55
the entire 'parameters_json' represents actually b
| |
| 39 ): | |
| 38 """Represents a try-job to be triggered through Buildbucket. | 40 """Represents a try-job to be triggered through Buildbucket. |
| 39 | 41 |
| 40 Tag for "user_agent" should not be set, as it will be added automatically. | 42 Tag for "user_agent" should not be set, as it will be added automatically. |
| 41 """ | 43 """ |
| 42 | 44 |
| 43 def ToBuildbucketRequest(self): | 45 def ToBuildbucketRequest(self): |
| 44 parameters_json = { | 46 parameters_json = { |
| 45 'builder_name': self.builder_name, | 47 'builder_name': self.builder_name, |
| 46 'properties': self.properties, | 48 'properties': self.properties, |
| 47 } | 49 } |
| 50 if self.additional_parameters: | |
| 51 parameters_json['additional_parameters'] = self.additional_parameters | |
| 48 if self.revision: | 52 if self.revision: |
| 49 parameters_json['changes'] = [ | 53 parameters_json['changes'] = [ |
| 50 { | 54 { |
| 51 'author': { | 55 'author': { |
| 52 'email': _ROLE_EMAIL, | 56 'email': _ROLE_EMAIL, |
| 53 }, | 57 }, |
| 54 'revision': self.revision, | 58 'revision': self.revision, |
| 55 }, | 59 }, |
| 56 ] | 60 ] |
| 57 | 61 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 else: | 188 else: |
| 185 error_content = { | 189 error_content = { |
| 186 'error': { | 190 'error': { |
| 187 'reason': status_code, | 191 'reason': status_code, |
| 188 'message': content | 192 'message': content |
| 189 } | 193 } |
| 190 } | 194 } |
| 191 json_results.append(error_content) | 195 json_results.append(error_content) |
| 192 | 196 |
| 193 return _ConvertFuturesToResults(json_results) | 197 return _ConvertFuturesToResults(json_results) |
| OLD | NEW |