OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 """Tool to interact with recipe repositories. | 3 """Tool to interact with recipe repositories. |
4 | 4 |
5 This tool operates on the nearest ancestor directory containing an | 5 This tool operates on the nearest ancestor directory containing an |
6 infra/config/recipes.cfg. | 6 infra/config/recipes.cfg. |
7 """ | 7 """ |
8 | 8 |
9 import argparse | 9 import argparse |
10 import json | 10 import json |
(...skipping 13 matching lines...) Expand all Loading... |
24 assert os.path.exists(args.package), ( | 24 assert os.path.exists(args.package), ( |
25 'Given recipes config file %s does not exist.' % args.package) | 25 'Given recipes config file %s does not exist.' % args.package) |
26 return ( | 26 return ( |
27 package.InfraRepoConfig().from_recipes_cfg(args.package), | 27 package.InfraRepoConfig().from_recipes_cfg(args.package), |
28 package.ProtoFile(args.package) | 28 package.ProtoFile(args.package) |
29 ) | 29 ) |
30 | 30 |
31 | 31 |
32 def simulation_test(package_deps, args): | 32 def simulation_test(package_deps, args): |
33 from recipe_engine import simulation_test | 33 from recipe_engine import simulation_test |
34 simulation_test.main(package_deps, args=json.loads(args.args)) | 34 from recipe_engine import loader |
| 35 |
| 36 _, config_file = get_package_config(args) |
| 37 universe = loader.RecipeUniverse(package_deps, config_file.path) |
| 38 |
| 39 simulation_test.main(universe, args=json.loads(args.args)) |
35 | 40 |
36 | 41 |
37 def lint(package_deps, args): | 42 def lint(package_deps, args): |
38 from recipe_engine import lint_test | 43 from recipe_engine import lint_test |
39 lint_test.main(package_deps, args.whitelist or []) | 44 lint_test.main(package_deps, args.whitelist or []) |
40 | 45 |
41 | 46 |
42 def handle_recipe_return(recipe_result, result_filename, stream): | 47 def handle_recipe_return(recipe_result, result_filename, stream): |
43 if 'recipe_result' in recipe_result.result: | 48 if 'recipe_result' in recipe_result.result: |
44 result_string = json.dumps( | 49 result_string = json.dumps( |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 elif args.properties_file: | 99 elif args.properties_file: |
95 properties = get_properties_from_file(args.properties_file) | 100 properties = get_properties_from_file(args.properties_file) |
96 else: | 101 else: |
97 properties = arg_properties | 102 properties = arg_properties |
98 | 103 |
99 properties['recipe'] = args.recipe | 104 properties['recipe'] = args.recipe |
100 | 105 |
101 os.environ['PYTHONUNBUFFERED'] = '1' | 106 os.environ['PYTHONUNBUFFERED'] = '1' |
102 os.environ['PYTHONIOENCODING'] = 'UTF-8' | 107 os.environ['PYTHONIOENCODING'] = 'UTF-8' |
103 | 108 |
104 universe = loader.RecipeUniverse(package_deps) | 109 _, config_file = get_package_config(args) |
| 110 universe = loader.RecipeUniverse(package_deps, config_file.path) |
105 | 111 |
106 workdir = (args.workdir or | 112 workdir = (args.workdir or |
107 os.path.join(os.path.dirname(os.path.realpath(__file__)), 'workdir')) | 113 os.path.join(os.path.dirname(os.path.realpath(__file__)), 'workdir')) |
108 logging.info('Using %s as work directory' % workdir) | 114 logging.info('Using %s as work directory' % workdir) |
109 if not os.path.exists(workdir): | 115 if not os.path.exists(workdir): |
110 os.makedirs(workdir) | 116 os.makedirs(workdir) |
111 | 117 |
112 old_cwd = os.getcwd() | 118 old_cwd = os.getcwd() |
113 os.chdir(workdir) | 119 os.chdir(workdir) |
114 stream = annotator.StructuredAnnotationStream() | 120 stream = annotator.StructuredAnnotationStream() |
115 | 121 |
116 try: | 122 try: |
117 ret = recipe_run.run_steps(properties, stream, universe=universe) | 123 ret = recipe_run.run_steps(properties, stream, universe=universe) |
118 | |
119 finally: | 124 finally: |
120 os.chdir(old_cwd) | 125 os.chdir(old_cwd) |
121 | 126 |
122 return handle_recipe_return(ret, args.result_file, stream) | 127 return handle_recipe_return(ret, args.result_file, stream) |
123 | 128 |
124 | 129 |
125 def roll(args): | 130 def roll(args): |
126 from recipe_engine import package | 131 from recipe_engine import package |
127 repo_root, config_file = get_package_config(args) | 132 repo_root, config_file = get_package_config(args) |
128 context = package.PackageContext.from_proto_file(repo_root, config_file) | 133 context = package.PackageContext.from_proto_file(repo_root, config_file) |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 | 335 |
331 Warmly, | 336 Warmly, |
332 recipes.py | 337 recipes.py |
333 """ | 338 """ |
334 return 1 | 339 return 1 |
335 | 340 |
336 return 0 | 341 return 0 |
337 | 342 |
338 if __name__ == '__main__': | 343 if __name__ == '__main__': |
339 sys.exit(main()) | 344 sys.exit(main()) |
OLD | NEW |