diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 108: Empty the pexpect buffer before sending the next command over the serial

Message ID 20110914160813.11711.85479.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Paul Larson Sept. 14, 2011, 4:08 p.m. UTC
Merge authors:
  Le Chi Thu le.chi.thu@linaro.org <le.chi.thu@linaro.org>
Related merge proposals:
  https://code.launchpad.net/~le-chi-thu/lava-dispatcher/empty-pexpect-buffer/+merge/74951
  proposed by: Le Chi Thu (le-chi-thu)
------------------------------------------------------------
revno: 108 [merge]
committer: Paul Larson <paul.larson@canonical.com>
branch nick: big-dispatcher-merge
timestamp: Wed 2011-09-14 09:43:58 -0500
message:
  Empty the pexpect buffer before sending the next command over the serial
  line
modified:
  lava_dispatcher/actions/lava-test.py
  lava_dispatcher/client.py


--
lp:lava-dispatcher
https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk

You are subscribed to branch lp:lava-dispatcher.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava_dispatcher/actions/lava-test.py'
--- lava_dispatcher/actions/lava-test.py	2011-09-10 03:24:21 +0000
+++ lava_dispatcher/actions/lava-test.py	2011-09-14 14:43:58 +0000
@@ -72,7 +72,6 @@ 
         client.run_shell_command(
             'chroot /mnt/root lava-test help',
             response="list-test", timeout=10)
-        client.proc.expect(client.master_str, timeout=10)
     except:
         tb = traceback.format_exc()
         client.sio.write(tb)

=== modified file 'lava_dispatcher/client.py'
--- lava_dispatcher/client.py	2011-09-10 03:24:21 +0000
+++ lava_dispatcher/client.py	2011-09-14 14:43:58 +0000
@@ -150,6 +150,7 @@ 
         self.proc.sendline("hardreset")
 
     def run_shell_command(self, cmd, response=None, timeout=-1):
+        self.empty_pexpect_buffer()
         # return return-code if captured, else return None
         self.proc.sendline(cmd)
         #verify return value of last command, match one number at least
@@ -222,6 +223,10 @@ 
     def get_seriallog(self):
         return self.sio.getvalue()
 
+    def empty_pexpect_buffer(self):
+        index = 0
+        while (index == 0):
+            index = self.proc.expect (['.+', pexpect.EOF, pexpect.TIMEOUT], timeout=1)
 
 class SerialIO(file):
     def __init__(self, logfile):