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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 if args: | 106 if args: |
107 parser.error('Unrecognized args: %s' % ' '.join(args)) | 107 parser.error('Unrecognized args: %s' % ' '.join(args)) |
108 return set_commit(obj, options.issue, '0') | 108 return set_commit(obj, options.issue, '0') |
109 | 109 |
110 | 110 |
111 def CMDbuilders(parser, args): | 111 def CMDbuilders(parser, args): |
112 """Prints json-formatted list of builders given a path to cq.cfg file. | 112 """Prints json-formatted list of builders given a path to cq.cfg file. |
113 | 113 |
114 The output is a dictionary in the following format: | 114 The output is a dictionary in the following format: |
115 { | 115 { |
116 'master_name': { | 116 'master_name': [ |
117 'builder_name': { | 117 'builder_name', |
118 'custom_property': 'value', | 118 'another_builder' |
119 'testfilter': 'compile' | 119 ], |
120 }, | 120 'another_master': [ |
121 'another_builder': {} | 121 'third_builder' |
122 }, | 122 ] |
123 'another_master': { | |
124 'third_builder': {} | |
125 } | |
126 } | 123 } |
127 """ | 124 """ |
128 _, args = parser.parse_args(args) | 125 _, args = parser.parse_args(args) |
129 if len(args) != 1: | 126 if len(args) != 1: |
130 parser.error('Expected a single path to CQ config. Got: %s' % | 127 parser.error('Expected a single path to CQ config. Got: %s' % |
131 ' '.join(args)) | 128 ' '.join(args)) |
132 | 129 |
133 with open(args[0]) as config_file: | 130 with open(args[0]) as config_file: |
134 cq_config = config_file.read() | 131 cq_config = config_file.read() |
135 | 132 |
136 config = cq_pb2.Config() | 133 config = cq_pb2.Config() |
137 text_format.Merge(cq_config, config) | 134 text_format.Merge(cq_config, config) |
138 masters = {} | 135 masters = {} |
139 if config.HasField('verifiers') and config.verifiers.HasField('try_job'): | 136 if config.HasField('verifiers') and config.verifiers.HasField('try_job'): |
140 for bucket in config.verifiers.try_job.buckets: | 137 for bucket in config.verifiers.try_job.buckets: |
141 masters.setdefault(bucket.name, {}) | 138 masters.setdefault(bucket.name, []) |
142 for builder in bucket.builders: | 139 for builder in bucket.builders: |
143 if not builder.HasField('experiment_percentage'): | 140 if not builder.HasField('experiment_percentage'): |
144 masters[bucket.name].setdefault(builder.name, {}) | 141 masters[bucket.name].append(builder.name) |
145 print json.dumps(masters) | 142 print json.dumps(masters) |
146 | 143 |
147 CMDbuilders.func_usage_more = '<path-to-cq-config>' | 144 CMDbuilders.func_usage_more = '<path-to-cq-config>' |
148 | 145 |
149 ############################################################################### | 146 ############################################################################### |
150 ## Boilerplate code | 147 ## Boilerplate code |
151 | 148 |
152 | 149 |
153 class OptionParser(optparse.OptionParser): | 150 class OptionParser(optparse.OptionParser): |
154 """An OptionParser instance with default options. | 151 """An OptionParser instance with default options. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 return CMDhelp(parser, args) | 223 return CMDhelp(parser, args) |
227 | 224 |
228 | 225 |
229 if __name__ == "__main__": | 226 if __name__ == "__main__": |
230 fix_encoding.fix_encoding() | 227 fix_encoding.fix_encoding() |
231 try: | 228 try: |
232 sys.exit(main()) | 229 sys.exit(main()) |
233 except KeyboardInterrupt: | 230 except KeyboardInterrupt: |
234 sys.stderr.write('interrupted\n') | 231 sys.stderr.write('interrupted\n') |
235 sys.exit(1) | 232 sys.exit(1) |
OLD | NEW |