[Pkg-privacy-commits] [tails-installer] 12/30: Make writing images report progress in Windows

Intrigeri intrigeri at moszumanska.debian.org
Wed May 24 15:27:09 UTC 2017


This is an automated email from the git hooks/post-receive script.

intrigeri pushed a commit to tag 3.92.0
in repository tails-installer.

commit fe216006642149aa579645a48fc04106fa4c21ea
Author: Martin Bříza <m at rtinbriza.cz>
Date:   Tue Apr 5 15:31:22 2016 +0200

    Make writing images report progress in Windows
---
 liveusb/components/DownloadDialog.qml |  3 ++-
 liveusb/creator.py                    | 19 +++++++++++++------
 liveusb/gui.py                        | 29 ++---------------------------
 3 files changed, 17 insertions(+), 34 deletions(-)

diff --git a/liveusb/components/DownloadDialog.qml b/liveusb/components/DownloadDialog.qml
index 9327958..1ca940e 100644
--- a/liveusb/components/DownloadDialog.qml
+++ b/liveusb/components/DownloadDialog.qml
@@ -197,7 +197,8 @@ Dialog {
                             }
                             AdwaitaProgressBar {
                                 width: parent.width
-                                value: liveUSBData.currentImage.writer.running ? liveUSBData.currentImage.writer.progress / liveUSBData.currentImage.writer.maxProgress : 0
+                                value: liveUSBData.currentImage.writer.progress
+                                onValueChanged: console.log("OMG " + value)
                                 visible: !liveUSBData.currentImage.download.running
                                 progressColor: liveUSBData.currentImage.writer.checking ? Qt.lighter("green") : "red"
                             }
diff --git a/liveusb/creator.py b/liveusb/creator.py
index 48a31ee..5c0a449 100755
--- a/liveusb/creator.py
+++ b/liveusb/creator.py
@@ -32,6 +32,7 @@ import subprocess
 import sys
 import time
 from StringIO import StringIO
+from argparse import _AppendAction
 from stat import ST_SIZE
 
 from liveusb import _
@@ -593,19 +594,25 @@ class WindowsLiveUSBCreator(LiveUSBCreator):
         dd = subprocess.Popen([(os.path.dirname(sys.argv[0]) if len(os.path.dirname(sys.argv[0])) else os.path.dirname(os.path.realpath(__file__))+'/..')+'/tools/dd.exe',
                                'bs=1M',
                                'if='+self.iso,
-                               'of=\\\\.\\PHYSICALDRIVE'+self.drive.device],
+                               'of=\\\\.\\PHYSICALDRIVE'+self.drive.device,
+                               '--size',
+                               '--progress'],
                               shell=True,
                               stdout=subprocess.PIPE,
-                              stderr=subprocess.STDOUT)
+                              stderr=subprocess.STDOUT,
+                              bufsize=1,
+                              universal_newlines=True)
         if update_function:
             while dd.poll() is None:
-                buf = dd.stdout.read(256)
-                r = re.match(buf, '^[^ ]+ ([0-9]+)%')
-                if r and len(r.groups()) == 2:
-                    update_function(float(r.group(1)/100.0))
+                buf = dd.stdout.readline().strip()
+                #buf = dd.stdout.read(256)
+                r = re.search('^([,0-9]+)', buf)
+                if r and len(r.groups()) > 0 and len(r.group(0)) > 0:
+                    update_function(float(r.group(0).replace(',', '')) / self.isosize)
         else:
             dd.wait()
 
+    def restore_drive(self, d, callback):
 
 
         """
diff --git a/liveusb/gui.py b/liveusb/gui.py
index f64badf..5d9caf0 100755
--- a/liveusb/gui.py
+++ b/liveusb/gui.py
@@ -45,6 +45,7 @@ from PyQt5.QtCore import pyqtProperty, pyqtSlot, QObject, QUrl, QDateTime, pyqtS
 from PyQt5.QtGui import QGuiApplication
 from PyQt5.QtQml import qmlRegisterType, qmlRegisterUncreatableType, QQmlComponent, QQmlApplicationEngine, QQmlListProperty, QQmlEngine
 from PyQt5 import QtQuick
+from setuptools.sandbox import save_pkg_resources_state
 
 import resources_rc
 import qml_rc
@@ -89,7 +90,6 @@ class ReleaseDownloadThread(QThread):
                 break
         try:
             iso = self.grabber.urlgrab(self.progress.release.url, filename=filename, reget='simple')
-            print iso
         except URLGrabError, e:
             # TODO find out if this errno is _really_ benign
             if e.errno == 9: # Requested byte range not satisfiable.
@@ -204,9 +204,6 @@ class ReleaseWriterThread(QThread):
         self.parent = parent
 
     def run(self):
-        # TODO move this to the backend
-        #handler = LiveUSBLogHandler(self.parent.status)
-        #self.live.log.addHandler(handler)
         now = datetime.now()
         try:
             self.ddImage(now)
@@ -216,20 +213,14 @@ class ReleaseWriterThread(QThread):
             self.live.log.exception(e)
 
         self.parent.running = False
-        #self.live.log.removeHandler(handler)
 
     def ddImage(self, now):
         # TODO move this to the backend
         self.live.dd_image(self.update_progress)
-        #self.live.log.removeHandler(handler)
-        #duration = str(datetime.now() - now).split('.')[0]
         self.parent.status = 'Finished!'
         self.parent.finished = True
         return
 
-    def set_max_progress(self, maximum):
-        self.parent.maxProgress = maximum
-
     def update_progress(self, value):
         self.parent.progress = value
 
@@ -237,13 +228,11 @@ class ReleaseWriter(QObject):
     """ Here we can track the progress of the writing and control it """
     runningChanged = pyqtSignal()
     currentChanged = pyqtSignal()
-    maximumChanged = pyqtSignal()
     statusChanged = pyqtSignal()
     finishedChanged = pyqtSignal()
 
     _running = False
     _current = -1.0
-    _maximum = -1.0
     _status = ''
     _finished = False
 
@@ -256,19 +245,15 @@ class ReleaseWriter(QObject):
     def reset(self):
         self._running = False
         self._current = -1.0
-        self._maximum = -1.0
         self.runningChanged.emit()
         self.currentChanged.emit()
-        self.maximumChanged.emit()
 
     @pyqtSlot()
     def run(self):
         self._running = True
         self._current = 0.0
-        self._maximum = 100.0
         self.runningChanged.emit()
         self.currentChanged.emit()
-        self.maximumChanged.emit()
         self.status = 'Writing'
         self.worker.start()
 
@@ -287,19 +272,9 @@ class ReleaseWriter(QObject):
             self._running = value
             self.runningChanged.emit()
 
-    @pyqtProperty(float, notify=maximumChanged)
-    def maxProgress(self):
-        return self._maximum
-
-    @maxProgress.setter
-    def maxProgress(self, value):
-        if (value != self._maximum):
-            self._maximum = value
-            self.maximumChanged.emit()
-
     @pyqtProperty(float, notify=currentChanged)
     def progress(self):
-        return self._current
+        return float(self._current)
 
     @progress.setter
     def progress(self, value):

-- 
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