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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: build/android/buildbot/bb_utils.py
diff --git a/build/android/buildbot/bb_utils.py b/build/android/buildbot/bb_utils.py
new file mode 100644
index 0000000000000000000000000000000000000000..8dd9f9a0a32aaee2e4cf2e6411d04de36bb7bf4e
--- /dev/null
+++ b/build/android/buildbot/bb_utils.py
@@ -0,0 +1,77 @@
+# Copyright (c) 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import json
+import optparse
+import os
+import pipes
+import subprocess
+import sys
+
+sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
+from pylib import buildbot_report
+from pylib import constants
+
+
+TESTING = 'BUILDBOT_TESTING' in os.environ
+
+BB_BUILD_DIR = os.path.abspath(
+ os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir,
+ os.pardir, os.pardir, os.pardir, os.pardir))
+
+
+def SpawnCmd(command):
+ """Spawn a process without waiting for termination."""
+ 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.
+ sys.stdout.flush()
+ if TESTING:
+ class MockPopen(object):
+ @staticmethod
+ def wait():
+ return 0
+ return MockPopen()
+
+ return subprocess.Popen(command, cwd=constants.CHROME_DIR)
+
+
+def RunCmd(command, flunk_on_failure=True, halt_on_failure=False,
+ warning_code=88):
+ """Run a command relative to the chrome source root."""
+ code = SpawnCmd(command).wait()
+ 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.
+ if code != 0:
+ print 'ERROR: process exited with code %d' % code
+ if flunk_on_failure and code != warning_code:
+ buildbot_report.PrintError()
+ else:
+ buildbot_report.PrintWarning()
+ # Allow steps to have both halting (i.e. 1) and non-halting exit codes.
+ 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.
+ raise OSError()
+ return code
+
+
+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.
+ setattr(parser.values, option.dest, json.loads(value))
+
+
+def GetParser():
+ parser = optparse.OptionParser()
+ parser.add_option('--build-properties', action='callback',
+ callback=ConvertJson, type='string', default={},
+ help='build properties in JSON format')
+ parser.add_option('--factory-properties', action='callback',
+ callback=ConvertJson, type='string', default={},
+ help='factory properties in JSON format')
+ parser.add_option('--slave-properties', action='callback',
+ callback=ConvertJson, type='string', default={},
+ help='Properties set by slave script in JSON format')
+
+ return parser
+
+
+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.
+ """Returns quoted command that can be run in bash shell."""
+ return ' '.join(map(pipes.quote, command))
+

Powered by Google App Engine
This is Rietveld 408576698