sysmobts-calib attempt at nonblocking shell output

Change-Id: I94dca825203920804367d66cda13e49c2927faab
This commit is contained in:
Neels Hofmeyr 2019-09-12 03:34:03 +02:00
parent 58785ddb26
commit d33bbf770f
1 changed files with 22 additions and 0 deletions

View File

@ -17,6 +17,8 @@ import subprocess
import re
import shlex
import argparse
import select
import time
calib_val_re = re.compile(r'clock-calibration +([0-9]+)')
result_re = re.compile('The calibration value is: ([0-9]*)')
@ -48,6 +50,26 @@ def call_output(*cmd):
o,e = p.communicate()
return o.decode('utf-8')
# # read the command and echo nonblocking
# p_select = select.poll()
# p_select.register(p.stdout, select.POLLIN)
#
# o = []
#
# while True:
# if p_select.poll(1):
# if p.stdout.readable:
# output = p.stdout.readline().decode('utf-8')
# o.append(output)
# sys.stdout.write(output)
# sys.stdout.flush()
# else:
# time.sleep(.25)
# if p.poll() is not None:
# break
#
# return ''.join(o)
def call(*cmd):
o = call_output(*cmd)
if o: