[Pkg-privacy-commits] [tails-installer] 27/210: Finishing touches in the downloader
Intrigeri
intrigeri at moszumanska.debian.org
Wed May 24 15:26:25 UTC 2017
This is an automated email from the git hooks/post-receive script.
intrigeri pushed a commit to tag 3.90.0
in repository tails-installer.
commit c6337e8e602f3b0126f11c01db0caf53cfc8efd8
Author: Martin Briza <mbriza at redhat.com>
Date: Wed Feb 25 11:28:39 2015 +0100
Finishing touches in the downloader
---
liveusb/components/DownloadDialog.qml | 2 +-
liveusb/components/ImageDetails.qml | 1 -
liveusb/gui.py | 69 ++++++++++++++++++++++++++++++-----
3 files changed, 61 insertions(+), 11 deletions(-)
diff --git a/liveusb/components/DownloadDialog.qml b/liveusb/components/DownloadDialog.qml
index d9b720f..77e919a 100644
--- a/liveusb/components/DownloadDialog.qml
+++ b/liveusb/components/DownloadDialog.qml
@@ -106,7 +106,7 @@ Dialog {
color: "red"
textColor: enabled ? "white" : palette.text
width: implicitWidth * 1.2
- enabled: false
+ enabled: liveUSBData.downloader.readyToWrite
text: "Write to disk"
}
}
diff --git a/liveusb/components/ImageDetails.qml b/liveusb/components/ImageDetails.qml
index e628ed1..0eabea3 100644
--- a/liveusb/components/ImageDetails.qml
+++ b/liveusb/components/ImageDetails.qml
@@ -47,7 +47,6 @@ Item {
width: implicitWidth + 16
onClicked: {
dlDialog.visible = true
- console.log(liveUSBData.currentImage.url)
liveUSBData.downloader.run(liveUSBData.currentImage.url)
}
enabled: mainWindow.currentImageIndex != 0 || fileDialog.fileUrl.length > 0
diff --git a/liveusb/gui.py b/liveusb/gui.py
index b97df1f..6db81e8 100755
--- a/liveusb/gui.py
+++ b/liveusb/gui.py
@@ -136,6 +136,9 @@ class Release(QObject):
return self._url
class IsoDownloaderThread(QThread):
+ downloadFinished = pyqtSignal(str)
+ downloadError = pyqtSignal(str)
+
def __init__(self, url, progress, proxies):
QThread.__init__(self)
self.url = url
@@ -153,20 +156,26 @@ class IsoDownloaderThread(QThread):
try:
iso = self.grabber.urlgrab(self.url, reget='simple')
except URLGrabError, e:
- pass
- self.emit(QtCore.SIGNAL("dlcomplete(PyQt_PyObject)"), e.strerror)
+ # TODO find out if this errno is _really_ benign
+ if e.errno == 9: # Requested byte range not satisfiable.
+ self.downloadFinished.emit(filename)
+ else:
+ self.downloadError.emit(e.strerror)
else:
- pass
- self.emit(QtCore.SIGNAL("dlcomplete(PyQt_PyObject)"), iso)
+ self.downloadFinished.emit(iso)
class IsoDownloader(QObject, BaseMeter):
maxProgressChanged = pyqtSignal()
progressChanged = pyqtSignal()
statusChanged = pyqtSignal()
+ readyToWriteChanged = pyqtSignal()
+ isoPathChanged = pyqtSignal()
- _status = "Initializing"
+ _status = 'Initializing'
_maximum = -1.0
_current = -1.0
+ _readyToWrite = False
+ _isoPath = ''
""" A QObject urlgrabber BaseMeter class.
@@ -181,7 +190,7 @@ class IsoDownloader(QObject, BaseMeter):
def start(self, filename=None, url=None, basename=None, size=None, now=None, text=None):
self._maximum = size
- self._status = "Starting"
+ self._status = 'Starting'
self.statusChanged.emit()
def update(self, amount_read, now=None):
@@ -192,7 +201,7 @@ class IsoDownloader(QObject, BaseMeter):
if self._current < amount_read:
self._current = amount_read
self.progressChanged.emit()
- self._status = "Downloading"
+ self._status = 'Downloading'
self.statusChanged.emit()
def end(self, amount_read):
@@ -200,16 +209,43 @@ class IsoDownloader(QObject, BaseMeter):
self.progressChanged.emit()
@pyqtSlot(str)
+ def childFinished(self, iso):
+ print(iso)
+ self._status = 'Ready to write'
+ self._maximum = -1.0
+ self._current = -1.0
+ self._readyToWrite = True
+ self._isoPath = iso
+ self.statusChanged.emit()
+ self.progressChanged.emit()
+ self.maxProgressChanged.emit()
+ self.readyToWriteChanged.emit()
+ self.isoPathChanged.emit()
+
+ @pyqtSlot(str)
+ def childError(self, err):
+ self._status = 'Error: ' + err
+ self._maximum = -1.0
+ self._current = -1.0
+ self.statusChanged.emit()
+ self.progressChanged.emit()
+ self.maxProgressChanged.emit()
+
+ @pyqtSlot(str)
def run(self, url):
self._grabber = IsoDownloaderThread(url, self, self._live.get_proxies())
self._grabber.start()
+ self._grabber.downloadFinished.connect(self.childFinished)
+ self._grabber.downloadError.connect(self.childError)
@pyqtSlot()
def cancel(self):
self._grabber.terminate()
- self._status = "Initializing..."
+ self._status = 'Initializing...'
self._maximum = -1.0
- self._current = 1.0
+ self._current = -1.0
+ self._readyToWrite = False
+ self._isoPath = ''
self.statusChanged.emit()
self.progressChanged.emit()
self.maxProgressChanged.emit()
@@ -226,6 +262,19 @@ class IsoDownloader(QObject, BaseMeter):
def progress(self):
return self._current
+ @pyqtProperty(bool, notify=readyToWriteChanged)
+ def readyToWrite(self):
+ return self._readyToWrite
+
+ @pyqtProperty(str, notify=isoPathChanged)
+ def isoPath(self):
+ return self._isoPath
+
+class WriterThread(QThread):
+
+ def __init__(self, live, parent):
+ QThread.__init__(self, parent)
+
class LiveUSBData(QObject):
releasesChanged = pyqtSignal()
@@ -272,6 +321,8 @@ class LiveUSBData(QObject):
def currentImage(self):
return self.releaseData[self._currentIndex]
+
+
class LiveUSBApp(QApplication):
""" Main application class """
def __init__(self, opts, args):
--
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