aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xtools/gcl_try95
1 files changed, 95 insertions, 0 deletions
diff --git a/tools/gcl_try b/tools/gcl_try
new file mode 100755
index 0000000000..7552b96dd2
--- /dev/null
+++ b/tools/gcl_try
@@ -0,0 +1,95 @@
+#!/usr/bin/python
+
+# 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.
+
+"""
+gcl_try: Submit a try request.
+
+This is a thin wrapper around "gcl try" which adds some validation.
+"""
+
+
+import argparse
+import httplib
+import json
+import os
+import subprocess
+import sys
+
+
+ALL_BUILDERS = 'all'
+SKIA_BUILD_MASTER_HOST = '70.32.156.51'
+SKIA_BUILD_MASTER_PORT = '10117'
+TRYBOT_SUFFIX = '_Trybot'
+
+
+def RetrieveTrybotList():
+ """ Retrieve the list of known trybots from the build master, stripping
+ TRYBOT_SUFFIX from the name. """
+ trybots = []
+ connection = httplib.HTTPConnection(SKIA_BUILD_MASTER_HOST,
+ SKIA_BUILD_MASTER_PORT)
+ httplib.HTTPConnection
+ connection.request('GET', '/json/builders')
+ response = connection.getresponse()
+ builders = json.load(response)
+ for builder in builders:
+ if builder.endswith(TRYBOT_SUFFIX):
+ trybots.append(builder[:-len(TRYBOT_SUFFIX)])
+ return trybots
+
+
+def ValidateArgs(trybots):
+ """ Parse and validate command-line arguments. If the arguments are valid,
+ returns a tuple of (<changelist name>, <list of trybots>).
+
+ trybots: A list of the known try builders.
+ """
+ parser = argparse.ArgumentParser(
+ prog=os.path.basename(__file__),
+ description='%(prog)s: Submit a try request.',
+ usage='%(prog)s [-h] <changelist> --bot <buildername> [<buildername ...]')
+ parser.add_argument('changelist', metavar='<changelist>',
+ help='Changelist to try.')
+ parser.add_argument('--bot', metavar='<buildername>', nargs='+',
+ help='Builder(s) on which to try the change. One of: %s'
+ % ', '.join(trybots),
+ choices=trybots, required=True)
+ args = parser.parse_args()
+ if args.bot == [ALL_BUILDERS]:
+ bots = trybots
+ else:
+ bots = args.bot
+ return args.changelist, bots
+
+
+def SubmitTryRequest(changelist, bots):
+ """ Submits a try request for the given changelist on the given list of
+ trybots.
+
+ changelist: string; the name of the changelist to try.
+ bots: list of trybots on which to run the try.
+ """
+ if os.name == 'nt':
+ gcl = 'gcl.bat'
+ else:
+ gcl = 'gcl'
+ cmd = [gcl, 'try', changelist, '--bot',
+ ','.join(['%s%s' % (bot, TRYBOT_SUFFIX) for bot in bots])]
+ print 'Running command: %s' % ' '.join(cmd)
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ if proc.wait() != 0:
+ raise Exception('Failed to submit try request:\n%s' % proc.communicate()[0])
+ print proc.communicate()[0]
+
+
+def main():
+ trybots = RetrieveTrybotList()
+ changelist, bots = ValidateArgs(trybots=trybots)
+ SubmitTryRequest(changelist, bots)
+
+
+if __name__ == '__main__':
+ sys.exit(main()) \ No newline at end of file