diff options
| author | Donald Delmar Davis <ddavis3@jaguarlandrover.com> | 2014-12-11 01:15:05 +0000 |
|---|---|---|
| committer | Donald Delmar Davis <ddavis3@jaguarlandrover.com> | 2014-12-11 01:15:05 +0000 |
| commit | 3abdacc7c353cf70a454bc5690bb872d7551a03f (patch) | |
| tree | e6dd33f291cd3da922d5776ff4dc15163c599d15 /loader.py | |
| parent | 05393a0051c3589385978c513a16650a0ceab02d (diff) | |
test push from target
Diffstat (limited to 'loader.py')
| -rwxr-xr-x | loader.py | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -1,6 +1,30 @@ #!/usr/bin/env python3 from dialog import Dialog +from threading import Thread +import subprocess +import sys, os +import contextlib + +#http://blog.thelinuxkid.com/2013/06/get-python-subprocess-output-without.html +def read_stderr_realtime(proc, stream='stderr'): + newlines = ['\n', '\r\n', '\r'] + stream = getattr(proc, stream) + with contextlib.closing(stream): + while True: + out = [] + last = stream.read(1) + # Don't loop forever + if last == '' and proc.poll() is not None: + break + while last not in newlines: + # Don't loop forever + if last == '' and proc.poll() is not None: + break + out.append(last) + last = stream.read(1) + out = ''.join(out) + yield out d = Dialog(dialog="dialog") d.set_background_title("Select file to load.....") |
