OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 """Access the commit queue from the command line. | 6 """Access the commit queue from the command line. |
7 """ | 7 """ |
8 | 8 |
9 __version__ = '0.1' | 9 __version__ = '0.1' |
10 | 10 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 _apply_on_issue(_get_commit, obj, issue) | 98 _apply_on_issue(_get_commit, obj, issue) |
99 | 99 |
100 def set_commit(obj, issue, flag): | 100 def set_commit(obj, issue, flag): |
101 """Sets the commit bit flag on an issue.""" | 101 """Sets the commit bit flag on an issue.""" |
102 def _set_commit(properties): | 102 def _set_commit(properties): |
103 print obj.set_flag(issue, properties['patchsets'][-1], 'commit', flag) | 103 print obj.set_flag(issue, properties['patchsets'][-1], 'commit', flag) |
104 return 0 | 104 return 0 |
105 _apply_on_issue(_set_commit, obj, issue) | 105 _apply_on_issue(_set_commit, obj, issue) |
106 | 106 |
107 | 107 |
108 def get_master_builder_map(config_path): | 108 def get_master_builder_map( |
| 109 config_path, include_experimental=True, include_triggered=True): |
109 """Returns a map of master -> [builders] from cq config.""" | 110 """Returns a map of master -> [builders] from cq config.""" |
110 with open(config_path) as config_file: | 111 with open(config_path) as config_file: |
111 cq_config = config_file.read() | 112 cq_config = config_file.read() |
112 | 113 |
113 config = cq_pb2.Config() | 114 config = cq_pb2.Config() |
114 text_format.Merge(cq_config, config) | 115 text_format.Merge(cq_config, config) |
115 masters = {} | 116 masters = {} |
116 if config.HasField('verifiers') and config.verifiers.HasField('try_job'): | 117 if config.HasField('verifiers') and config.verifiers.HasField('try_job'): |
117 for bucket in config.verifiers.try_job.buckets: | 118 for bucket in config.verifiers.try_job.buckets: |
118 masters.setdefault(bucket.name, []) | 119 masters.setdefault(bucket.name, []) |
119 for builder in bucket.builders: | 120 for builder in bucket.builders: |
120 if not builder.HasField('experiment_percentage'): | 121 if (not include_experimental and |
121 masters[bucket.name].append(builder.name) | 122 builder.HasField('experiment_percentage')): |
| 123 continue |
| 124 if (not include_triggered and |
| 125 builder.HasField('triggered_by')): |
| 126 continue |
| 127 masters[bucket.name].append(builder.name) |
122 return masters | 128 return masters |
123 | 129 |
124 | 130 |
125 @need_issue | 131 @need_issue |
126 def CMDset(parser, args): | 132 def CMDset(parser, args): |
127 """Sets the commit bit.""" | 133 """Sets the commit bit.""" |
128 options, args, obj = parser.parse_args(args) | 134 options, args, obj = parser.parse_args(args) |
129 if args: | 135 if args: |
130 parser.error('Unrecognized args: %s' % ' '.join(args)) | 136 parser.error('Unrecognized args: %s' % ' '.join(args)) |
131 return set_commit(obj, options.issue, '1') | 137 return set_commit(obj, options.issue, '1') |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 return CMDhelp(parser, args) | 274 return CMDhelp(parser, args) |
269 | 275 |
270 | 276 |
271 if __name__ == "__main__": | 277 if __name__ == "__main__": |
272 fix_encoding.fix_encoding() | 278 fix_encoding.fix_encoding() |
273 try: | 279 try: |
274 sys.exit(main()) | 280 sys.exit(main()) |
275 except KeyboardInterrupt: | 281 except KeyboardInterrupt: |
276 sys.stderr.write('interrupted\n') | 282 sys.stderr.write('interrupted\n') |
277 sys.exit(1) | 283 sys.exit(1) |
OLD | NEW |