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

Unified Diff: scripts/run_cmd.py

Issue 201623006: run_cmd: Run commands in the checkout root (Closed) Base URL: https://skia.googlesource.com/buildbot.git@master
Patch Set: Created 6 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/run_cmd.py
diff --git a/scripts/run_cmd.py b/scripts/run_cmd.py
index cd749f66482c9d7336b93c0508d1cda7db48c210..740f26f2a5a4efac526b354989420c5fedb5f8a2 100755
--- a/scripts/run_cmd.py
+++ b/scripts/run_cmd.py
@@ -248,15 +248,19 @@ def _fixup_cmd(cmd, slave_host_name):
return new_cmd
-def _launch_cmd(cmd):
+def _launch_cmd(cmd, cwd=None):
"""Launch the given command. Non-blocking.
Args:
cmd: list of strings; command to run.
+ cwd: working directory in which to run the process. Defaults to the root
+ of the buildbot checkout containing this file.
Returns:
subprocess.Popen instance.
"""
- return subprocess.Popen(cmd, shell=False, stderr=subprocess.PIPE,
+ if not cwd:
+ cwd = buildbot_path
+ return subprocess.Popen(cmd, shell=False, cwd=cwd, stderr=subprocess.PIPE,
stdout=subprocess.PIPE)
@@ -307,9 +311,10 @@ def run_on_local_slaves(cmd):
results = {}
procs = []
for (slave, _) in slaves:
- os.chdir(os.path.join(buildbot_path, slave, 'buildbot'))
try:
- procs.append((slave, _launch_cmd(cmd)))
+ proc = _launch_cmd(cmd, cwd=os.path.join(buildbot_path, slave,
+ 'buildbot'))
+ procs.append((slave, proc))
except OSError as e:
results[slave] = SingleCommandResults.make(stderr=str(e))
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698