aboutsummaryrefslogtreecommitdiff
path: root/loader.py
diff options
context:
space:
mode:
Diffstat (limited to 'loader.py')
-rwxr-xr-xloader.py36
1 files changed, 34 insertions, 2 deletions
diff --git a/loader.py b/loader.py
index ba0fcec..512b6e7 100755
--- a/loader.py
+++ b/loader.py
@@ -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()
+