Chromium Code Reviews| Index: recipe_engine/run.py |
| diff --git a/recipe_engine/run.py b/recipe_engine/run.py |
| index 6949ee70212269c415831ca60fb64b10cbd630e9..03e8d21f2f1716f9e24cd30f4e3e49e2d9898442 100644 |
| --- a/recipe_engine/run.py |
| +++ b/recipe_engine/run.py |
| @@ -72,6 +72,7 @@ import os |
| import re |
| import subprocess |
| import sys |
| +import tempfile |
| import threading |
| import traceback |
| @@ -433,7 +434,7 @@ def run_steps(properties, |
| 'TESTING_SLAVENAME' in os.environ)): |
| properties['use_mirror'] = False |
| - engine = RecipeEngine(stream, properties, test_data) |
| + engine = RecipeEngine(stream, properties, test_data, universe) |
| # Create all API modules and top level RunSteps function. It doesn't launch |
| # any recipe code yet; RunSteps needs to be called. |
| @@ -750,16 +751,21 @@ class RecipeEngine(object): |
| * step - uses engine.create_step(...). |
| """ |
| - def __init__(self, stream, properties, test_data): |
| + def __init__(self, stream, properties, test_data, universe): |
| self._stream = stream |
| self._properties = properties |
| self._test_data = test_data |
| self._step_history = collections.OrderedDict() |
| + self._universe = universe |
| self._previous_step_annotation = None |
| self._previous_step_result = None |
| self._api = None |
| + def clone(self, stream=None, properties=None, universe=None): |
| + return RecipeEngine(stream or self._stream, properties or self._properties, |
| + self._test_data, universe or self._universe) |
| + |
| @property |
| def properties(self): |
| return self._properties |
| @@ -861,11 +867,12 @@ class RecipeEngine(object): |
| raise exc(step['name'], step_result) |
| - |
| def run(self, recipe_script, api): |
| """Run a recipe represented by a recipe_script object. |
| This function blocks until recipe finishes. |
| + It mainly executes the recipe, and has some exception handling logic, and |
| + adds the step history to the result. |
| Args: |
| recipe_script: The recipe to run, as represented by a RecipeScript object. |
| @@ -940,4 +947,21 @@ class RecipeEngine(object): |
| """ |
| return step.as_jsonish() |
| + def depend_on(self, recipe, properties, distributor=None): |
| + if self._test_data.enabled: |
| + # TODO(martiniss) test properties against the recipe |
| + return self._test_data.depend_on_data[recipe][1] |
|
Paweł Hajdan Jr.
2015/11/13 12:30:00
It's not obvious to me why [1] is needed at the en
martiniss
2015/11/13 23:19:03
Changed.
|
| + elif True: # is_local |
|
Paweł Hajdan Jr.
2015/11/13 12:30:00
nit: "elif True" looks weird. Why not "else" with
martiniss
2015/11/13 23:19:03
Dedented, and added a todo to add DM stuff.
|
| + recipes_py_loc = os.path.join( |
| + self._universe.package_deps._context.repo_root, 'recipes.py') |
| + |
| + with tempfile.NamedTemporaryFile() as f: |
| + cmd = ['python', recipes_py_loc, |
|
Sergiy Byelozyorov
2015/11/13 13:14:55
please use sys.executable here
martiniss
2015/11/13 23:19:03
Fixed.
|
| + '--package=%s' % self._universe._config_file, 'run', |
| + '--result-file=%s' % f.name, recipe] |
| + cmd.extend(['%s=%s' % (k, v) for k, v in properties.iteritems()]) |
| + |
| + rval = subprocess.call(cmd) |
|
Sergiy Byelozyorov
2015/11/13 13:14:55
So currently this would run recipe engine with ano
|
| + return json.load(f) |
|
Sergiy Byelozyorov
2015/11/13 13:14:55
I wonder if we should also return rval here... per
martiniss
2015/11/13 23:19:03
I talked to estaab, and we agreed that what depend
Sergiy Byelozyorov
2015/11/17 11:19:40
Please add a TODO if you are planning to make chan
|
| + |