[Pkg-privacy-commits] [tails-installer] 09/30: Adjust paths so it can run as a script in Windows

Intrigeri intrigeri at moszumanska.debian.org
Wed May 24 15:27:08 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 9251b0c11ef93e872dc86bdc327ffc6bd0c7cf3a
Author: Martin Bříza <m at rtinbriza.cz>
Date:   Mon Apr 4 11:28:45 2016 +0200

    Adjust paths so it can run as a script in Windows
---
 liveusb/creator.py | 14 ++++++++------
 liveusb/gui.py     | 48 +++---------------------------------------------
 2 files changed, 11 insertions(+), 51 deletions(-)

diff --git a/liveusb/creator.py b/liveusb/creator.py
index 16fe461..48a31ee 100755
--- a/liveusb/creator.py
+++ b/liveusb/creator.py
@@ -574,8 +574,6 @@ class WindowsLiveUSBCreator(LiveUSBCreator):
     def dd_image(self, update_function=None):
         import re
 
-        print("AAA")
-
         if update_function:
             update_function(-1.0)
 
@@ -592,14 +590,18 @@ class WindowsLiveUSBCreator(LiveUSBCreator):
 
         if update_function:
             update_function(0.0)
-        print("Writing" + self.iso)
-        dd = subprocess.Popen([os.path.dirname(sys.argv[0])+'/tools/dd.exe', 'bs=1M', 'if='+self.iso, 'of=\\\\.\\PHYSICALDRIVE'+self.drive.device], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+        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],
+                              shell=True,
+                              stdout=subprocess.PIPE,
+                              stderr=subprocess.STDOUT)
         if update_function:
             while dd.poll() is None:
                 buf = dd.stdout.read(256)
                 r = re.match(buf, '^[^ ]+ ([0-9]+)%')
-                print(buf)
-                if r:
+                if r and len(r.groups()) == 2:
                     update_function(float(r.group(1)/100.0))
         else:
             dd.wait()
diff --git a/liveusb/gui.py b/liveusb/gui.py
index f952df9..f64badf 100755
--- a/liveusb/gui.py
+++ b/liveusb/gui.py
@@ -193,54 +193,15 @@ class ReleaseDownload(QObject, BaseMeter):
             self._live.set_iso(value)
             self.pathChanged.emit()
 
-class ReleaseWriterProgressThread(QThread):
-    """ Periodically checks how the write progresses """
-    alive = True
-    get_free_bytes = None
-    drive = None
-    totalSize = 0
-    orig_free = 0
-
-    def set_data(self, size, drive, freebytes):
-        self.totalSize = size / 1024
-        self.drive = drive
-        self.get_free_bytes = freebytes
-        if self.get_free_bytes:
-            self.orig_free = self.get_free_bytes()
-        else:
-            self.orig_free = 0
-        self.parent().maxProgress = self.totalSize
-
-    def run(self):
-        while self.alive:
-            if self.get_free_bytes:
-                free = self.get_free_bytes()
-            else:
-                free = 0
-            value = (self.orig_free - free) / 1024
-            self.parent().progress = value
-            if (value >= self.totalSize):
-                break
-            sleep(3)
-
-    def stop(self):
-        self.alive = False
-
-    def terminate(self):
-        self.parent().progress = self.totalSize
-        self.terminate()
-
 
 class ReleaseWriterThread(QThread):
     """ The actual write to the portable drive """
 
-    def __init__(self, parent, progressThread):
+    def __init__(self, parent):
         QThread.__init__(self, parent)
 
         self.live = parent.live
         self.parent = parent
-        self.progressThread = progressThread
-
 
     def run(self):
         # TODO move this to the backend
@@ -259,12 +220,11 @@ class ReleaseWriterThread(QThread):
 
     def ddImage(self, now):
         # TODO move this to the backend
-        self.live.dd_image()
+        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
-        self.progressThread.stop()
         return
 
     def set_max_progress(self, maximum):
@@ -291,8 +251,7 @@ class ReleaseWriter(QObject):
         QObject.__init__(self, parent)
         self.live = parent.live
         self.release = parent
-        self.progressWatcher = ReleaseWriterProgressThread(self)
-        self.worker = ReleaseWriterThread(self, self.progressWatcher)
+        self.worker = ReleaseWriterThread(self)
 
     def reset(self):
         self._running = False
@@ -315,7 +274,6 @@ class ReleaseWriter(QObject):
 
     @pyqtSlot()
     def cancel(self):
-        self.progressWatcher.stop()
         self.worker.terminate()
         self.reset()
 

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