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

Unified Diff: scripts/slave/dump_factory_properties.py

Issue 1178733003: Modify annotated_run to read factory configs from the slave checkout. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 5 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
« scripts/slave/annotated_run.py ('K') | « scripts/slave/annotated_run.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/slave/dump_factory_properties.py
diff --git a/scripts/slave/dump_factory_properties.py b/scripts/slave/dump_factory_properties.py
new file mode 100644
index 0000000000000000000000000000000000000000..3fef1b077698ad323f9572811dde8231b0213850
--- /dev/null
+++ b/scripts/slave/dump_factory_properties.py
@@ -0,0 +1,85 @@
+#!/usr/bin/python
iannucci 2015/06/11 00:28:08 probably want to put this in scripts/tools
Dirk Pranke 2015/06/11 01:13:43 ok.
+
+import argparse
+import json
+import os
+import sys
+
+SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))
+sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir))
+
+import common.env
+
+common.env.Install()
+
+from common import master_cfg_utils
+from master import master_gen
+
+
+class Err(Exception):
+ pass
+
+
+def main(argv):
+
+ arg_parser = argparse.ArgumentParser()
+ arg_parser.add_argument('--output',
+ help='path to write JSON output to instead of stdout')
+ arg_parser.add_argument('mastername', nargs=1)
+ arg_parser.add_argument('buildername', nargs=1)
+ args = arg_parser.parse_args(argv)
+
+ buildername = args.buildername[0]
+ mastername = args.mastername[0]
+
+ props = {}
+ message = ''
+ result = 0
iannucci 2015/06/11 00:28:08 maybe 'ok' and make it a bool?
Dirk Pranke 2015/06/11 01:13:43 Actually, looking at this now, it might be better
+ try:
+ props = GetFactoryProperties(mastername, buildername)
+ except Exception as e:
+ message = str(e)
+ result = 1
+
+ output_str = json.dumps({
+ 'factory_properties': props,
+ 'message': message,
+ 'result': result
+ }, sort_keys=2, indent=2)
iannucci 2015/06/11 00:28:08 while 'sort_keys=2' technically works, you probabl
Dirk Pranke 2015/06/11 01:13:43 whoops, yes.
+
+ if args.output:
+ with open(args.output, 'w') as fp:
+ fp.write(output_str + '\n')
+ else:
+ print output_str
iannucci 2015/06/11 00:28:07 consider outfile = sys.stdout if args.output: o
Dirk Pranke 2015/06/11 01:13:43 That will close sys.stdout() at the end, which mig
+
+ return result
+
+
+def GetFactoryProperties(mastername, buildername):
+ master_list = master_cfg_utils.GetMasters()
+ master_path = None
+ for name, path in master_list:
+ if name == mastername:
+ master_path = path
+
+ if not master_path:
+ raise Err('master "%s" not found.' % mastername)
iannucci 2015/06/11 00:28:08 tbh... I would probably just raise Exception (sinc
Dirk Pranke 2015/06/11 01:13:43 Yeah, true, this is left over when I thought I wou
+
+ config = master_cfg_utils.LoadConfig(master_path, 'master.cfg')
Paweł Hajdan Jr. 2015/06/11 08:38:19 I think we have a very similar existing tool build
+
+ for builder_dict in config['BuildmasterConfig']['builders']:
+ if builder_dict['name'] == buildername:
+ return dict((k, v) for k, v, _ in
+ builder_dict['factory'].properties.asList())
+
+ raise Err('builder "%s" not found on in master "%s"' %
+ (buildername, mastername))
+
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[1:]))
+
+basedir = os.path
+from twisted.application import service
iannucci 2015/06/11 00:28:08 dare I ask?
Dirk Pranke 2015/06/11 01:13:43 whoops, bad cut and paste, I think.
« scripts/slave/annotated_run.py ('K') | « scripts/slave/annotated_run.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698