diff options
author | Stefan Stanacar <stefanx.stanacar@intel.com> | 2014-04-25 14:35:27 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-04-29 17:19:49 +0100 |
commit | be8f766f43d85c364b9706b464ed0a59d0fbf0b7 (patch) | |
tree | c5e6cdc0ad5bf62f3f9bfb3349a2a5795055d154 /meta/lib/oeqa/utils | |
parent | 1ebcbc6d77171b81dfe6432ffad6cae3148dcf2e (diff) | |
download | openembedded-core-be8f766f43d85c364b9706b464ed0a59d0fbf0b7.tar.gz openembedded-core-be8f766f43d85c364b9706b464ed0a59d0fbf0b7.tar.bz2 openembedded-core-be8f766f43d85c364b9706b464ed0a59d0fbf0b7.zip |
oeqa/utils: sshcontrol: realtime logging of output
Log the output of the command as it runs not when it finished, else
tail -f tmp/work/minnow-poky-linux/core-image-sato/1.0-r0/testimage/ssh_target_log
isn't as useful as it could be.
Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Diffstat (limited to 'meta/lib/oeqa/utils')
-rw-r--r-- | meta/lib/oeqa/utils/sshcontrol.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/meta/lib/oeqa/utils/sshcontrol.py b/meta/lib/oeqa/utils/sshcontrol.py index d355d5e8e9..1c81795a87 100644 --- a/meta/lib/oeqa/utils/sshcontrol.py +++ b/meta/lib/oeqa/utils/sshcontrol.py @@ -29,8 +29,15 @@ class SSHProcess(object): self.output = None self.process = None self.starttime = None + self.logfile = None - def run(self, command, timeout=None): + def log(self, msg): + if self.logfile: + with open(self.logfile, "a") as f: + f.write("%s" % msg) + + def run(self, command, timeout=None, logfile=None): + self.logfile = logfile self.starttime = time.time() output = '' self.process = subprocess.Popen(command, **self.options) @@ -45,8 +52,10 @@ class SSHProcess(object): eof = True else: output += data + self.log(data) endtime = time.time() + timeout + # process hasn't returned yet if not eof: self.process.terminate() @@ -55,9 +64,12 @@ class SSHProcess(object): self.process.kill() except OSError: pass - output += "\nProcess killed - no output for %d seconds. Total running time: %d seconds." % (timeout, time.time() - self.starttime) + lastline = "\nProcess killed - no output for %d seconds. Total running time: %d seconds." % (timeout, time.time() - self.starttime) + self.log(lastline) + output += lastline else: output = self.process.communicate()[0] + self.log(output.rstrip()) self.status = self.process.wait() self.output = output.rstrip() @@ -91,9 +103,8 @@ class SSHControl(object): self.log("[Running]$ %s" % " ".join(command)) proc = SSHProcess() - status, output = proc.run(command, timeout) + status, output = proc.run(command, timeout, logfile=self.logfile) - self.log("%s" % output) self.log("[Command returned '%d' after %.2f seconds]" % (status, time.time() - proc.starttime)) if status and not ignore_status: |