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

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

Issue 15261003: Add a new script bb_host_steps.py which handles all host side steps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 'Environment setup' is not a step Created 7 years, 6 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
OLDNEW
(Empty)
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import json
6 import optparse
7 import os
8 import pipes
9 import subprocess
10 import sys
11
12 sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
13 from pylib import buildbot_report
14 from pylib import constants
15
16
17 TESTING = 'BUILDBOT_TESTING' in os.environ
18
19 BB_BUILD_DIR = os.path.abspath(
20 os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir,
21 os.pardir, os.pardir, os.pardir, os.pardir))
22
23
24 def SpawnCmd(command):
25 """Spawn a process without waiting for termination."""
26 print '>', ' '.join(map(pipes.quote, command))
Isaac (away) 2013/06/06 21:26:46 use commandtostring()
Siva Chandra 2013/06/06 22:10:47 Done.
27 sys.stdout.flush()
28 if TESTING:
29 class MockPopen(object):
30 @staticmethod
31 def wait():
32 return 0
33 return MockPopen()
34
35 return subprocess.Popen(command, cwd=constants.CHROME_DIR)
36
37
38 def RunCmd(command, flunk_on_failure=True, halt_on_failure=False,
39 warning_code=88):
40 """Run a command relative to the chrome source root."""
41 code = SpawnCmd(command).wait()
42 print '<', ' '.join(map(pipes.quote, command))
Isaac (away) 2013/06/06 21:26:46 use commandtostring()
Siva Chandra 2013/06/06 22:10:47 Done.
43 if code != 0:
44 print 'ERROR: process exited with code %d' % code
45 if flunk_on_failure and code != warning_code:
46 buildbot_report.PrintError()
47 else:
48 buildbot_report.PrintWarning()
49 # Allow steps to have both halting (i.e. 1) and non-halting exit codes.
50 if code != 0 and code != 88 and halt_on_failure:
Isaac (away) 2013/06/06 21:26:46 can you change this line to if code != warning_co
Siva Chandra 2013/06/06 22:10:47 Done.
51 raise OSError()
52 return code
53
54
55 def ConvertJson(option, _, value, parser):
Isaac (away) 2013/06/06 21:26:46 nit, would be little cleaner to make this an inner
Siva Chandra 2013/06/06 22:10:47 Done.
56 setattr(parser.values, option.dest, json.loads(value))
57
58
59 def GetParser():
60 parser = optparse.OptionParser()
61 parser.add_option('--build-properties', action='callback',
62 callback=ConvertJson, type='string', default={},
63 help='build properties in JSON format')
64 parser.add_option('--factory-properties', action='callback',
65 callback=ConvertJson, type='string', default={},
66 help='factory properties in JSON format')
67 parser.add_option('--slave-properties', action='callback',
68 callback=ConvertJson, type='string', default={},
69 help='Properties set by slave script in JSON format')
70
71 return parser
72
73
74 def CommandToString(command):
Isaac (away) 2013/06/06 21:26:46 nit, move this to the top since it's used by funct
Siva Chandra 2013/06/06 22:10:47 Done.
75 """Returns quoted command that can be run in bash shell."""
76 return ' '.join(map(pipes.quote, command))
77
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698