[Pkg-privacy-commits] [tails-installer] 156/210: Improved warning/exception handling
Intrigeri
intrigeri at moszumanska.debian.org
Wed May 24 15:26:40 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 d0bef156c6f16f1af9f97f1c6a4a595857d9ecf0
Author: Martin Briza <mbriza at redhat.com>
Date: Fri Sep 4 17:07:03 2015 +0200
Improved warning/exception handling
---
liveusb/components/DownloadDialog.qml | 44 ++++++++++++++++++++++++-----------
liveusb/creator.py | 33 +++++++++++++++-----------
liveusb/gui.py | 18 +++++++-------
3 files changed, 58 insertions(+), 37 deletions(-)
diff --git a/liveusb/components/DownloadDialog.qml b/liveusb/components/DownloadDialog.qml
index 716b630..63b4062 100644
--- a/liveusb/components/DownloadDialog.qml
+++ b/liveusb/components/DownloadDialog.qml
@@ -360,18 +360,36 @@ Dialog {
}
SequentialAnimation {
id: acceptButtonBounce
- NumberAnimation {
- target: acceptButton
- property: "scale"
- duration: 80
- from: 1
- to: 1.2
+ ParallelAnimation {
+ ColorAnimation {
+ duration: 80
+ target: acceptButton
+ property: "color"
+ from: "red"
+ to: Qt.tint("white", "red")
+ }
+ NumberAnimation {
+ target: acceptButton
+ property: "scale"
+ duration: 80
+ from: 1
+ to: 1.2
+ }
}
- NumberAnimation {
- target: acceptButton
- property: "scale"
- duration: 40
- to: 1.0
+ ParallelAnimation {
+ ColorAnimation {
+ duration: 80
+ target: acceptButton
+ property: "color"
+ from: Qt.tint("white", "red")
+ to: "red"
+ }
+ NumberAnimation {
+ target: acceptButton
+ property: "scale"
+ duration: 40
+ to: 1.0
+ }
}
}
}
@@ -405,9 +423,9 @@ Dialog {
text: qsTranslate("", "Write the image immediately when the download is finished")
onCheckedChanged: {
if (checked)
- acceptButton.pressedOnce = false
- else
acceptButton.pressedOnce = true
+ else
+ acceptButton.pressedOnce = false
}
}
}
diff --git a/liveusb/creator.py b/liveusb/creator.py
index 2c703c1..33a1932 100755
--- a/liveusb/creator.py
+++ b/liveusb/creator.py
@@ -391,8 +391,9 @@ class LiveUSBCreator(object):
isoname = os.path.basename(self.iso)
for release in releases:
for arch in release['variants'].keys():
- if os.path.basename(release['variants'][arch]['url']) == isoname:
+ if arch in release['variants'].keys() and 'url' in release['variants'][arch] and os.path.basename(release['variants'][arch]['url']) == isoname:
return release
+ return None
def _set_drive(self, drive):
if drive == None:
@@ -849,6 +850,7 @@ class LinuxLiveUSBCreator(LiveUSBCreator):
shutil.rmtree(syslinux_path)
except OSError, e:
pass
+ print (self.dest, syslinux_path)
shutil.move(os.path.join(self.dest, "isolinux"), syslinux_path)
try:
os.unlink(os.path.join(syslinux_path, "isolinux.cfg"))
@@ -961,16 +963,16 @@ class LinuxLiveUSBCreator(LiveUSBCreator):
return
if partition.isFlagAvailable(parted.PARTITION_BOOT):
if partition.getFlag(parted.PARTITION_BOOT):
- self.log.debug(_('%s already bootable') % self._drive)
+ self.log.debug(_('%s already bootable') % self.drive['device'])
else:
partition.setFlag(parted.PARTITION_BOOT)
try:
disk.commit()
- self.log.info('Marked %s as bootable' % self._drive)
+ self.log.info('Marked %s as bootable' % self.drive['device'])
except Exception, e:
self.log.exception(e)
else:
- self.log.warning('%s does not have boot flag' % self._drive)
+ self.log.warning('%s does not have boot flag' % self.drive['device'])
def get_disk_partition(self):
""" Return the PedDisk and partition of the selected device """
@@ -979,7 +981,7 @@ class LinuxLiveUSBCreator(LiveUSBCreator):
dev = parted.Device(path = parent)
disk = parted.Disk(device = dev)
for part in disk.partitions:
- if self._drive == "/dev/%s" %(part.getDeviceNodeName(),):
+ if self.drive['device'] == "/dev/%s" %(part.getDeviceNodeName(),):
return disk, part
raise LiveUSBError(_("Unable to find partition"))
@@ -993,27 +995,30 @@ class LinuxLiveUSBCreator(LiveUSBCreator):
http://syslinux.zytor.com/doc/usbkey.txt
"""
#from parted import PedDevice
- self.log.info('Initializing %s in a zip-like fashon' % self._drive)
+ self.log.info('Initializing %s in a zip-like fashon' % self.drive['device'])
heads = 64
cylinders = 32
# Is this part even necessary?
#device = PedDevice.get(self._drive[:-1])
#cylinders = int(device.cylinders / (64 * 32))
self.popen('/usr/lib/syslinux/mkdiskimage -4 %s 0 %d %d' % (
- self._drive[:-1], heads, cylinders))
+ self.drive['device'][:-1], heads, cylinders))
def format_device(self):
""" Format the selected partition as FAT32 """
- self.log.info('Formatting %s as FAT32' % self._drive)
- self.popen('mkfs.vfat -F 32 %s' % self._drive)
+ self.log.info('Formatting %s as FAT32' % self.drive['device'])
+ self.popen('mkfs.vfat -F 32 %s' % self.drive['device'])
def get_mbr(self):
- parent = self.drive.get('parent', self._drive)
+ parent = self.drive.get('parent', self.drive['device'])
if parent is None:
- parent = self._drive
+ parent = self.drive['device']
parent = unicode(parent)
self.log.debug('Checking the MBR of %s' % parent)
- drive = open(parent, 'rb')
+ try:
+ drive = open(parent, 'rb')
+ except IOError:
+ return ''
mbr = ''.join(['%02X' % ord(x) for x in drive.read(2)])
drive.close()
self.log.debug('mbr = %r' % mbr)
@@ -1043,7 +1048,7 @@ class LinuxLiveUSBCreator(LiveUSBCreator):
return mbr == self.get_mbr()
def reset_mbr(self):
- parent = unicode(self.drive.get('parent', self._drive))
+ parent = unicode(self.drive.get('parent', self.drive['device']))
if '/dev/loop' not in self.drive:
mbr = self._get_mbr_bin()
if mbr:
@@ -1057,7 +1062,7 @@ class LinuxLiveUSBCreator(LiveUSBCreator):
def calculate_device_checksum(self, progress=None):
""" Calculate the SHA1 checksum of the device """
- self.log.info(_("Calculating the SHA1 of %s" % self._drive))
+ self.log.info(_("Calculating the SHA1 of %s" % self.drive['device']))
if not progress:
class DummyProgress:
def set_max_progress(self, value): pass
diff --git a/liveusb/gui.py b/liveusb/gui.py
index 1e60ec9..2cf7cb7 100755
--- a/liveusb/gui.py
+++ b/liveusb/gui.py
@@ -443,6 +443,8 @@ class Release(QObject):
self.live = live
self.liveUSBData = parent
+ self._size = 0
+
self._data = data
self._path = ''
@@ -481,6 +483,8 @@ class Release(QObject):
@pyqtSlot()
def inspectDestination(self):
+ if self._writer.running:
+ return
self._warning = []
self.warningChanged.emit()
self._info = []
@@ -503,7 +507,7 @@ class Release(QObject):
try:
self.live.mount_device()
except LiveUSBError, e:
- self.info = e.args[0]
+ self.addInfo(e.args[0])
self._running = False
self.runningChanged.emit()
except OSError, e:
@@ -536,12 +540,12 @@ class Release(QObject):
for arch in self._data['variants'].keys():
if arch in self._archMap[self.liveUSBData.releaseProxyModel.archFilter]:
return self._data['variants'][arch]['size']
- return 0
+ return self._size
@size.setter
def size(self, value):
- if value != self._size:
- self._data['x86_64']['size'] = value
+ if self.isLocal and self._size != value:
+ self._size = value
self.sizeChanged.emit()
@pyqtProperty('QStringList', constant=True)
@@ -625,12 +629,6 @@ class Release(QObject):
def info(self):
return self._info
- @info.setter
- def info(self, value):
- if self._info != value:
- self._info = value
- self.infoChanged.emit()
-
def addInfo(self, value):
if value not in self._info:
self._info.append(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