[Pkg-privacy-commits] [tails-installer] 157/210: Fix drive detection
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 8ee787f977abbecf1b331519397cac3a36d02c77
Author: Martin Briza <mbriza at redhat.com>
Date: Mon Sep 7 13:14:25 2015 +0200
Fix drive detection
---
liveusb/creator.py | 42 +++++++++++++++++++++++++++++++-----------
liveusb/gui.py | 4 ----
2 files changed, 31 insertions(+), 15 deletions(-)
diff --git a/liveusb/creator.py b/liveusb/creator.py
index 33a1932..a6309e2 100755
--- a/liveusb/creator.py
+++ b/liveusb/creator.py
@@ -518,6 +518,9 @@ class LinuxLiveUSBCreator(LiveUSBCreator):
'that does not support the ext4 filesystem'))
self.valid_fstypes -= set(['ext4'])
+ def strify(self, s):
+ return bytearray(s).replace(b'\x00', b'').decode('utf-8')
+
def detect_removable_drives(self, callback=None):
""" Detect all removable USB storage devices using UDisks2 via D-Bus """
import dbus
@@ -597,8 +600,6 @@ class LinuxLiveUSBCreator(LiveUSBCreator):
"/org/freedesktop/UDisks2")
self.udisks = dbus.Interface(udisks_obj, 'org.freedesktop.DBus.ObjectManager')
- def strify(s):
- return bytearray(s).replace(b'\x00', b'').decode('utf-8')
def handleAdded(name, device):
if ('org.freedesktop.UDisks2.Block' in device and
@@ -633,8 +634,8 @@ class LinuxLiveUSBCreator(LiveUSBCreator):
'fstype': str(blk['IdType']),
'fsversion': str(blk['IdVersion']),
'uuid': str(blk['IdUUID']),
- 'device': strify(blk['Device']),
- 'mount': map(strify, fs['MountPoints']),
+ 'device': self.strify(blk['Device']),
+ 'mount': map(self.strify, fs['MountPoints']),
'size': int(blk['Size']),
}
self.log.debug('data = %r' % data)
@@ -670,7 +671,7 @@ class LinuxLiveUSBCreator(LiveUSBCreator):
parent_obj = self.bus.get_object("org.freedesktop.UDisks2", partition[u'Table'])
parent = dbus.Interface(parent_obj, "org.freedesktop.DBus.Properties").Get("org.freedesktop.UDisks2.Block", "Device")
- data['parent'] = strify(parent)
+ data['parent'] = self.strify(parent)
self.log.debug(pformat(data))
@@ -737,20 +738,37 @@ class LinuxLiveUSBCreator(LiveUSBCreator):
self.dest = self.drive['mount']
mnt = None
if not self.dest:
+ dev=None
+ bd=None
try:
dev = self._get_device_fs(self.drive['udi'])
- self.log.debug("Mounting %s" % self.drive['device'])
bd = self.bus.get_object('org.freedesktop.UDisks2',
'/org/freedesktop/UDisks2/block_devices%s' %
self.drive['device'][4:])
- mnt = str(bd.Mount({}, dbus_interface='org.freedesktop.UDisks2.Filesystem'))
except dbus.exceptions.DBusException, e:
self.log.error(_('Unknown dbus exception while trying to '
- 'mount device: %s') % str(e))
- except Exception, e:
- raise LiveUSBError(_("Unable to mount device: %r" % e))
+ 'mount device: %s') % str(e))
- if not os.path.exists(mnt):
+ if dev and bd:
+ try:
+ mntpnts = dbus.Interface(bd, 'org.freedesktop.DBus.Properties').Get('org.freedesktop.UDisks2.Filesystem', 'MountPoints')
+ if len(mntpnts) > 0:
+ self.log.debug("%s is already mounted at %s" % (self.drive['device'], self.strify(mntpnts[0])))
+ mnt = self.strify(mntpnts[0])
+ except dbus.exceptions.DBusException, e:
+ pass
+
+ if dev and bd and not mnt:
+ try:
+ self.log.debug("Mounting %s" % self.drive['device'])
+ mnt = str(bd.Mount({}, dbus_interface='org.freedesktop.UDisks2.Filesystem'))
+ except dbus.exceptions.DBusException, e:
+ self.log.error(_('Unknown dbus exception while trying to '
+ 'mount device: %s') % str(e))
+ except Exception, e:
+ raise LiveUSBError(_("Unable to mount device: %r" % e))
+
+ if mnt and not os.path.exists(mnt):
self.log.error(_('No mount points found after mounting attempt'))
self.log.error("%s doesn't exist" % mnt)
else:
@@ -885,6 +903,8 @@ class LinuxLiveUSBCreator(LiveUSBCreator):
""" Return the number of available bytes on our device """
import statvfs
device = device and device or self.dest
+ if not device:
+ return 0
device = device.encode('utf-8')
if not os.path.exists(device):
raise LiveUSBError(_('Cannot find device: %s') % device)
diff --git a/liveusb/gui.py b/liveusb/gui.py
index 2cf7cb7..d7bac97 100755
--- a/liveusb/gui.py
+++ b/liveusb/gui.py
@@ -508,12 +508,8 @@ class Release(QObject):
self.live.mount_device()
except LiveUSBError, e:
self.addInfo(e.args[0])
- self._running = False
- self.runningChanged.emit()
except OSError, e:
self.addInfo(_('Unable to mount device'))
- self._running = False
- self.runningChanged.emit()
if self.live.existing_liveos() and not self.parent().option('dd'):
self.addWarning(_('Your device already contains a live OS. If you continue, it will be overwritten.'))
--
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