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

Side by Side Diff: scripts/tools/dump_master_cfg.py

Issue 1183563003: Re-land "Modify annotated_run to read factory configs from the slave checkout." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: fix sys.path in dump_master_cfg, improve logging 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « scripts/slave/annotated_run.py ('k') | scripts/tools/run_recipe.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 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """ 6 """
7 Dumps master config as JSON. 7 Dumps master config as JSON.
8 8
9 Uses master_cfg_utils.LoadConfig, which should be called at most once 9 Uses master_cfg_utils.LoadConfig, which should be called at most once
10 in the same process. That's why this is a separate utility. 10 in the same process. That's why this is a separate utility.
11 """ 11 """
12 12
13 import argparse 13 import argparse
14 import json 14 import json
15 import os 15 import os
16 import sys 16 import sys
17 17
18 SCRIPTS_DIR = os.path.abspath(
19 os.path.join(os.path.dirname(__file__), os.pardir))
20 if not SCRIPTS_DIR in sys.path:
21 sys.path.insert(0, SCRIPTS_DIR)
22
23 from common import env
24
25 env.Install()
26
18 from common import master_cfg_utils 27 from common import master_cfg_utils
19 from master.factory.build_factory import BuildFactory 28 from master.factory.build_factory import BuildFactory
20 29
21 30
22 class BuildbotJSONEncoder(json.JSONEncoder): 31 class BuildbotJSONEncoder(json.JSONEncoder):
23 def default(self, obj): # pylint: disable=E0202 32 def default(self, obj): # pylint: disable=E0202
24 if isinstance(obj, BuildFactory): 33 if isinstance(obj, BuildFactory):
25 return {'repr': repr(obj), 'properties': obj.properties.asDict()} 34 return {'repr': repr(obj), 'properties': obj.properties.asDict()}
26 35
27 return repr(obj) 36 return repr(obj)
28 37
29 38
30 def main(argv): 39 def main(argv):
31 parser = argparse.ArgumentParser() 40 parser = argparse.ArgumentParser()
32 parser.add_argument('master') 41 parser.add_argument('master')
33 parser.add_argument('output', type=argparse.FileType('w'), default=sys.stdout) 42 parser.add_argument('output', type=argparse.FileType('w'), default=sys.stdout)
34 43
35 args = parser.parse_args(argv) 44 args = parser.parse_args(argv)
36 45
37 result = master_cfg_utils.LoadConfig(args.master) 46 result = master_cfg_utils.LoadConfig(args.master)
38 json.dump(result['BuildmasterConfig'], 47 json.dump(result['BuildmasterConfig'],
39 args.output, 48 args.output,
40 cls=BuildbotJSONEncoder, 49 cls=BuildbotJSONEncoder,
41 indent=4) 50 indent=4)
42 return 0 51 return 0
43 52
44 53
45 if __name__ == '__main__': 54 if __name__ == '__main__':
46 sys.exit(main(sys.argv[1:])) 55 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « scripts/slave/annotated_run.py ('k') | scripts/tools/run_recipe.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698