aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Delmar Davis <ddavis3@jaguarlandrover.com>2014-12-11 19:26:28 +0000
committerDonald Delmar Davis <ddavis3@jaguarlandrover.com>2014-12-11 19:26:28 +0000
commit94f8c3f145d592bf1be3102599ee6d8113b562ec (patch)
tree9594f8343a23f3f39e13a97d7fc261eb3b3915f5
parent3abdacc7c353cf70a454bc5690bb872d7551a03f (diff)
rudiment ary loader
-rwxr-xr-x[-rw-r--r--]README.md0
-rwxr-xr-xloader.py36
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
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()
+