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

Side by Side Diff: scripts/slave/recipe_modules/python/api.py

Issue 23889036: Refactor the way that TestApi works so that it is actually useful. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: License headers Created 7 years, 2 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
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from slave import recipe_api 5 from slave import recipe_api
6 from slave import recipe_util
6 7
7 import textwrap 8 import textwrap
8 9
9 class PythonApi(recipe_api.RecipeApi): 10 class PythonApi(recipe_api.RecipeApi):
10 def __call__(self, name, script, args=None, unbuffered=True, **kwargs): 11 def __call__(self, name, script, args=None, unbuffered=True, **kwargs):
11 """Return a step to run a python script with arguments.""" 12 """Return a step to run a python script with arguments."""
12 cmd = ['python'] 13 cmd = ['python']
13 if unbuffered: 14 if unbuffered:
14 cmd.append('-u') 15 cmd.append('-u')
15 cmd.append(script) 16 cmd.append(script)
16 return self.m.step(name, cmd + list(args or []), **kwargs) 17 return self.m.step(name, cmd + list(args or []), **kwargs)
17 18
18 def inline(self, name, program, **kwargs): 19 def inline(self, name, program, **kwargs):
19 """Run an inline python program as a step. 20 """Run an inline python program as a step.
20 21
21 Program is output to a temp file and run when this step executes. 22 Program is output to a temp file and run when this step executes.
22 """ 23 """
23 program = textwrap.dedent(program) 24 program = textwrap.dedent(program)
24 compile(program, '<string>', 'exec', dont_inherit=1) 25 compile(program, '<string>', 'exec', dont_inherit=1)
25 26
26 @recipe_api.wrap_followup(kwargs) 27 @recipe_util.wrap_followup(kwargs)
27 def inline_followup(step_result): 28 def inline_followup(step_result):
28 step_result.presentation.logs['python.inline'] = program.splitlines() 29 step_result.presentation.logs['python.inline'] = program.splitlines()
29 30
30 return self(name, recipe_api.InputDataPlaceholder(program, '.py'), 31 return self(name, self.m.raw_io.input(program, '.py'),
31 followup_fn=inline_followup, **kwargs) 32 followup_fn=inline_followup, **kwargs)
OLDNEW
« no previous file with comments | « scripts/slave/recipe_modules/python/__init__.py ('k') | scripts/slave/recipe_modules/raw_io/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698