summaryrefslogtreecommitdiff
path: root/lib/runner.py
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-03-14 10:47:13 +0100
committerDaniel Friesel <derf@finalrewind.org>2019-03-14 10:47:13 +0100
commit0c70d3bc62a3cb58c4e411f1d64ff08691ccb1f4 (patch)
tree1bfaedd7739dc8cd9b56f0f422e27d727acba313 /lib/runner.py
parenta82a0e0e1973308a239851258287bfa6804eb7d7 (diff)
runner: fake peek support in ShellMonitor
Diffstat (limited to 'lib/runner.py')
-rw-r--r--lib/runner.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/runner.py b/lib/runner.py
index 87c41c5..fa08c01 100644
--- a/lib/runner.py
+++ b/lib/runner.py
@@ -84,7 +84,6 @@ class SerialMonitor:
Communication uses no parity, no flow control, and one stop bit.
Data collection starts immediately.
"""
- self.peek = peek
self.ser = serial.serial_for_url(port, do_not_open=True)
self.ser.baudrate = baud
self.ser.parity = 'N'
@@ -120,13 +119,14 @@ class SerialMonitor:
class ShellMonitor:
"""SerialMonitor runs a program and captures its output for a specific amount of time."""
- def __init__(self, script: str):
+ def __init__(self, script: str, peek = None):
"""
Create a new ShellMonitor object.
Does not start execution and monitoring yet.
"""
self.script = script
+ self.peek = peek
def run(self, timeout: int = 4) -> list:
"""
@@ -134,9 +134,13 @@ class ShellMonitor:
stderr and return status are discarded at the moment.
"""
+ if type(timeout) != int:
+ raise ValueError('timeout argument must be int')
res = subprocess.run(['timeout', '{:d}s'.format(timeout), self.script],
stdout = subprocess.PIPE, stderr = subprocess.PIPE,
universal_newlines = True)
+ if self.peek:
+ print(res.stdout)
return res.stdout.split('\n')
def monitor(self):