Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: build/android/buildbot/bb_run_bot.py

Issue 18325030: [Android] Refactor so that few pieces can be reused downstream. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | build/android/buildbot/tests/bb_run_bot_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 import collections 7 import collections
8 import copy 8 import copy
9 import json 9 import json
10 import os 10 import os
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 202
203 def GetRunBotOptParser(): 203 def GetRunBotOptParser():
204 parser = bb_utils.GetParser() 204 parser = bb_utils.GetParser()
205 parser.add_option('--bot-id', help='Specify bot id directly.') 205 parser.add_option('--bot-id', help='Specify bot id directly.')
206 parser.add_option('--testing', action='store_true', 206 parser.add_option('--testing', action='store_true',
207 help='For testing: print, but do not run commands') 207 help='For testing: print, but do not run commands')
208 208
209 return parser 209 return parser
210 210
211 211
212 def main(argv): 212 def GetBotConfig(options, bot_step_map):
213 parser = GetRunBotOptParser()
214 options, args = parser.parse_args(argv[1:])
215 if args:
216 parser.error('Unused args: %s' % args)
217
218 bot_id = options.bot_id or options.factory_properties.get('android_bot_id') 213 bot_id = options.bot_id or options.factory_properties.get('android_bot_id')
219 if not bot_id: 214 if not bot_id:
220 parser.error('A bot id must be specified through option or factory_props.') 215 print (sys.stderr,
216 'A bot id must be specified through option or factory_props.')
217 return
221 218
222 bot_config = GetBestMatch(GetBotStepMap(), bot_id) 219 bot_config = GetBestMatch(bot_step_map, bot_id)
223 if not bot_config: 220 if not bot_config:
224 print 'Error: config for id="%s" cannot be inferred.' % bot_id 221 print 'Error: config for id="%s" cannot be inferred.' % bot_id
225 return 1 222 return bot_config
226 223
227 print 'Using config:', bot_config
228 224
229 commands = GetCommands(options, bot_config) 225 def RunBotCommands(options, commands, env):
230 for command in commands:
231 print 'Will run: ', bb_utils.CommandToString(command)
232 print
233
234 env = GetEnvironment(bot_config.host_obj, options.testing)
235 print 'Environment changes:' 226 print 'Environment changes:'
236 print DictDiff(dict(os.environ), env) 227 print DictDiff(dict(os.environ), env)
237 228
238 for command in commands: 229 for command in commands:
239 print bb_utils.CommandToString(command) 230 print bb_utils.CommandToString(command)
240 sys.stdout.flush() 231 sys.stdout.flush()
241 if options.testing: 232 if options.testing:
242 env['BUILDBOT_TESTING'] = '1' 233 env['BUILDBOT_TESTING'] = '1'
243 return_code = subprocess.call(command, cwd=bb_utils.CHROME_SRC, env=env) 234 return_code = subprocess.call(command, cwd=bb_utils.CHROME_SRC, env=env)
244 if return_code != 0: 235 if return_code != 0:
245 return return_code 236 return return_code
246 237
247 238
239 def main(argv):
240 parser = GetRunBotOptParser()
241 options, args = parser.parse_args(argv[1:])
242 if args:
243 parser.error('Unused args: %s' % args)
244
245 bot_config = GetBotConfig(options, GetBotStepMap())
246 if not bot_config:
247 sys.exit(1)
248
249 print 'Using config:', bot_config
250
251 commands = GetCommands(options, bot_config)
252 for command in commands:
253 print 'Will run: ', bb_utils.CommandToString(command)
254 print
255
256 env = GetEnvironment(bot_config.host_obj, options.testing)
257 return RunBotCommands(options, commands, env)
258
259
248 if __name__ == '__main__': 260 if __name__ == '__main__':
249 sys.exit(main(sys.argv)) 261 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | build/android/buildbot/tests/bb_run_bot_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698