summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorshoward <showard@592f7852-d20e-0410-864c-8624ca9c26a4>2009-06-22 18:14:41 +0000
committershoward <showard@592f7852-d20e-0410-864c-8624ca9c26a4>2009-06-22 18:14:41 +0000
commitd901c6f5a4210c1d85c84bef776da9208862fb08 (patch)
treeacfa85856d38869ff13936a4030313b2581343a3 /server
parent7a47f12cbe65812b57dc9f6bb9ad6ff99e720f2e (diff)
* make utils.system* default to directing output to the logging module, instead of sys.std*. this involved refactoring the code out of ssh_host/paramiko_host/abstrash_ssh, which previously did the same thing (they still do, but now the use the common logic in utils)
* change packages.py to suppress command output properly. it was using the verbose option previously, which was added to ssh_host.run() and paramiko_host.run() specifically for this call site. in this context, verbose=False meant "dont print the command and dont print the output either). but this doesn't make the interface of utils.run(), for which verbose=False just means "dont print the command", because utils.run() suppresses output by default (while *host.run() doesn't). to resolve that, i made verbose on *host.run() match the interface of utils.run(), and i made packages.py suppress the output properly by passing stdout_tee=None. * move tee.flush() calls in utils.BgJob code to where it makes more sense (and interacts with LoggingFiles better) Signed-off-by: Steve Howard <showard@google.com> git-svn-id: svn://test.kernel.org/autotest/trunk@3307 592f7852-d20e-0410-864c-8624ca9c26a4
Diffstat (limited to 'server')
-rw-r--r--server/hosts/abstract_ssh.py8
-rw-r--r--server/hosts/paramiko_host.py7
-rw-r--r--server/hosts/ssh_host.py14
3 files changed, 8 insertions, 21 deletions
diff --git a/server/hosts/abstract_ssh.py b/server/hosts/abstract_ssh.py
index ee6556d7..9548264e 100644
--- a/server/hosts/abstract_ssh.py
+++ b/server/hosts/abstract_ssh.py
@@ -418,11 +418,3 @@ class AbstractSSHHost(SiteHost):
raise # only want to raise if it's a space issue
except Exception:
pass # autotest dir may not exist, etc. ignore
-
-
- def _get_stream_tee_file(self, stream, level, verbose):
- if stream is not TEE_TO_LOGS:
- return stream
- if not verbose:
- return None
- return logging_manager.LoggingFile(level=level)
diff --git a/server/hosts/paramiko_host.py b/server/hosts/paramiko_host.py
index 2cc1b372..3b80cdf6 100644
--- a/server/hosts/paramiko_host.py
+++ b/server/hosts/paramiko_host.py
@@ -194,8 +194,7 @@ class ParamikoHost(abstract_ssh.AbstractSSHHost):
def run(self, command, timeout=3600, ignore_status=False,
- stdout_tee=abstract_ssh.TEE_TO_LOGS,
- stderr_tee=abstract_ssh.TEE_TO_LOGS,
+ stdout_tee=utils.TEE_TO_LOGS, stderr_tee=utils.TEE_TO_LOGS,
connect_timeout=30, verbose=True):
"""
Run a command on the remote host.
@@ -218,8 +217,8 @@ class ParamikoHost(abstract_ssh.AbstractSSHHost):
AutoservSSHTimeout: ssh connection has timed out
"""
- stdout = self._get_stream_tee_file(stdout_tee, logging.DEBUG, verbose)
- stderr = self._get_stream_tee_file(stderr_tee, logging.ERROR, verbose)
+ stdout = utils.get_stream_tee_file(stdout_tee, logging.DEBUG)
+ stderr = utils.get_stream_tee_file(stderr_tee, logging.ERROR)
if verbose:
logging.debug("ssh-paramiko: %s" % command)
diff --git a/server/hosts/ssh_host.py b/server/hosts/ssh_host.py
index 5bfe1685..36baabe7 100644
--- a/server/hosts/ssh_host.py
+++ b/server/hosts/ssh_host.py
@@ -89,8 +89,7 @@ class SSHHost(abstract_ssh.AbstractSSHHost):
def run(self, command, timeout=3600, ignore_status=False,
- stdout_tee=abstract_ssh.TEE_TO_LOGS,
- stderr_tee=abstract_ssh.TEE_TO_LOGS,
+ stdout_tee=utils.TEE_TO_LOGS, stderr_tee=utils.TEE_TO_LOGS,
connect_timeout=30, options='', stdin=None, verbose=True):
"""
Run a command on the remote host.
@@ -113,23 +112,20 @@ class SSHHost(abstract_ssh.AbstractSSHHost):
execution was not 0
AutoservSSHTimeout: ssh connection has timed out
"""
- stdout = self._get_stream_tee_file(stdout_tee, logging.DEBUG, verbose)
- stderr = self._get_stream_tee_file(stderr_tee, logging.ERROR, verbose)
-
if verbose:
logging.debug("ssh: %s" % command)
env = " ".join("=".join(pair) for pair in self.env.iteritems())
try:
try:
- return self._run(command, timeout, ignore_status, stdout,
- stderr, connect_timeout, env, options,
+ return self._run(command, timeout, ignore_status, stdout_tee,
+ stderr_tee, connect_timeout, env, options,
stdin=stdin)
except error.AutoservSshPermissionDeniedError:
logging.error("Permission denied to ssh; re-running with "
"increased logging:")
try:
- self._run(command, timeout, ignore_status, stdout,
- stderr, connect_timeout, env, '-v -v -v',
+ self._run(command, timeout, ignore_status, stdout_tee,
+ stderr_tee, connect_timeout, env, '-v -v -v',
stdin=stdin)
except Exception:
pass