diff options
| -rwxr-xr-x[-rw-r--r--] | README.md | 0 | ||||
| -rwxr-xr-x | loader.py | 36 |
2 files changed, 34 insertions, 2 deletions
diff --git a/README.md b/README.md index f954b7d..f954b7d 100644..100755 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ from threading import Thread import subprocess import sys, os import contextlib +import time + #http://blog.thelinuxkid.com/2013/06/get-python-subprocess-output-without.html def read_stderr_realtime(proc, stream='stderr'): @@ -30,6 +32,36 @@ d = Dialog(dialog="dialog") d.set_background_title("Select file to load.....") code, selection = d.fselect('/mnt/images/',10,70) if code == d.OK : - d.set_background_title("loading:" +selection) - d.pause("Something should happen here",15,70,15) + + cmd = ['pv', '-n', selection ] + try: + output=open('/dev/sda','w') + except: + print("Can't open target disk" ) + pass + try: + proc = subprocess.Popen( + cmd, + stdout=output, + stderr=subprocess.PIPE, + universal_newlines=True, + ) + + d.set_background_title("loading:" +selection) + d.gauge_start("Progress",10,70,0) + + for line in read_stderr_realtime(proc): + if line.strip() == '': + continue + if "No such file" in line.strip(): + break + d.gauge_update(int(line.strip())) + if int(line.strip()) == 100: + d.gauge_update(100, "Finished!") + break + except IOError: + print ('oops') + + exit_code = d.gauge_stop() + |
