[Pkg-privacy-commits] [tails-installer] 01/21: Show progress of writing in Linux
Intrigeri
intrigeri at moszumanska.debian.org
Wed May 24 15:27:26 UTC 2017
This is an automated email from the git hooks/post-receive script.
intrigeri pushed a commit to tag 3.93.0
in repository tails-installer.
commit cc80a01e23ac12b056df7caaf24bd6934e8e834a
Author: Martin Briza <mbriza at redhat.com>
Date: Thu Apr 14 13:39:05 2016 +0200
Show progress of writing in Linux
Fixes #41
---
liveusb/creator.py | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/liveusb/creator.py b/liveusb/creator.py
index fa86eb3..f68361f 100755
--- a/liveusb/creator.py
+++ b/liveusb/creator.py
@@ -31,6 +31,7 @@ import signal
import subprocess
import sys
import time
+import re
from StringIO import StringIO
from argparse import _AppendAction
from stat import ST_SIZE
@@ -353,9 +354,24 @@ class LinuxLiveUSBCreator(LiveUSBCreator):
def dd_image(self, update_function=None):
self.log.info(_('Overwriting device with live image'))
drive = self.drive.device
- cmd = 'dd if="%s" of="%s" bs=1M iflag=direct oflag=direct conv=fdatasync' % (self.iso, drive)
- self.log.debug(_('Running') + ' %s' % cmd)
- self.popen(cmd)
+ cmd = ['dd', 'if=%s'%self.iso, 'of=%s'%drive, 'bs=1M', 'iflag=direct', 'oflag=direct', 'conv=fdatasync', 'status=progress']
+
+ if update_function:
+ update_function(0.0)
+
+ self.log.debug(_('Running'), cmd)
+ dd = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=0, universal_newlines=True)
+
+ if update_function:
+ while dd.poll() is None:
+ buf = dd.stdout.readline()
+ match = re.search('([0-9]+) bytes', buf)
+ if match:
+ update_function(float(match.group(1)) / self.isosize)
+ else:
+ dd.wait()
+
+ update_function(1.0)
def terminate(self):
for pid in self.pids:
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/tails-installer.git
More information about the Pkg-privacy-commits
mailing list