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

Unified Diff: server/hosts/logfile_monitor.py

Issue 6124004: Revert "Merge remote branch 'cros/upstream' into autotest-rebase" (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: Created 9 years, 11 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 | « server/hosts/factory.py ('k') | server/hosts/remote.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: server/hosts/logfile_monitor.py
diff --git a/server/hosts/logfile_monitor.py b/server/hosts/logfile_monitor.py
index 9595cc82adaad7c80eac825b4ec722d8108a1eea..1608a6be0b62c3c1dad9a5ce87761b5a14288d52 100644
--- a/server/hosts/logfile_monitor.py
+++ b/server/hosts/logfile_monitor.py
@@ -26,6 +26,15 @@ class FollowFilesLaunchError(Error):
"""Error occurred launching followfiles remotely."""
+def run_cmd_on_host(hostname, cmd, stdin, stdout, stderr):
+ base_cmd = abstract_ssh.make_ssh_command()
+ full_cmd = "%s %s \"%s\"" % (base_cmd, hostname,
+ server_utils.sh_escape(cmd))
+
+ return subprocess.Popen(full_cmd, stdin=stdin, stdout=stdout,
+ stderr=stderr, shell=True)
+
+
def list_remote_pythons(host):
"""List out installed pythons on host."""
result = host.run('ls /usr/bin/python[0-9]*')
@@ -63,24 +72,25 @@ def launch_remote_followfiles(host, lastlines_dirpath, follow_paths):
raise FollowFilesLaunchError('No supported Python on host.')
remote_monitordir = copy_monitordir(host)
- remote_script_path = os.path.join(remote_monitordir, 'followfiles.py')
+ remote_script_path = os.path.join(
+ remote_monitordir, 'followfiles.py')
followfiles_cmd = '%s %s --lastlines_dirpath=%s %s' % (
supported_python, remote_script_path,
lastlines_dirpath, ' '.join(follow_paths))
- remote_ff_proc = subprocess.Popen(host._make_ssh_cmd(followfiles_cmd),
- stdin=open(os.devnull, 'r'),
- stdout=subprocess.PIPE, shell=True)
-
-
+ devnull_r = open(os.devnull, 'r')
+ devnull_w = open(os.devnull, 'w')
+ remote_followfiles_proc = run_cmd_on_host(
+ host.hostname, followfiles_cmd, stdout=subprocess.PIPE,
+ stdin=devnull_r, stderr=devnull_w)
# Give it enough time to crash if it's going to (it shouldn't).
time.sleep(5)
- doa = remote_ff_proc.poll()
+ doa = remote_followfiles_proc.poll()
if doa:
raise FollowFilesLaunchError('ssh command crashed.')
- return remote_ff_proc
+ return remote_followfiles_proc
def resolve_patterns_path(patterns_path):
« no previous file with comments | « server/hosts/factory.py ('k') | server/hosts/remote.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698