[Pkg-privacy-commits] [tails-installer] 34/210: Detect the right sizes for the target devices
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 45592c5ed6de57b557de44298b4da53a80d0a624
Author: Martin Briza <mbriza at redhat.com>
Date: Tue Mar 3 12:59:32 2015 +0100
Detect the right sizes for the target devices
---
liveusb/creator.py | 6 ++++++
liveusb/gui.py | 23 +++++++++++++----------
2 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/liveusb/creator.py b/liveusb/creator.py
index 81eb7db..0d86848 100755
--- a/liveusb/creator.py
+++ b/liveusb/creator.py
@@ -529,6 +529,7 @@ class LinuxLiveUSBCreator(LiveUSBCreator):
list(dev.Get(device, 'PartitionFlags'))),
'parent': None,
'size': int(dev.Get(device, 'DeviceSize')),
+ 'fullSize': int(dev.Get(device, 'DeviceSize')),
'model': str(dev.Get(device, 'DriveModel')),
'vendor': str(dev.Get(device, 'DriveVendor'))
}
@@ -561,6 +562,11 @@ class LinuxLiveUSBCreator(LiveUSBCreator):
data['parent'] = str(dbus.Interface(self._get_device(parent),
'org.freedesktop.DBus.Properties').Get(parent,
'DeviceFile'))
+ print(data['parent'])
+ data['fullSize'] = int(dbus.Interface(self._get_device(parent),
+ 'org.freedesktop.DBus.Properties').Get(parent,
+ 'DeviceSize'))
+ print(data['fullSize'])
mount = data['mount']
if mount:
diff --git a/liveusb/gui.py b/liveusb/gui.py
index 917c283..62df55e 100755
--- a/liveusb/gui.py
+++ b/liveusb/gui.py
@@ -487,19 +487,22 @@ class LiveUSBData(QObject):
else:
name = device
+ gb = 1000.0 # if it's decided to use base 2 values, change this
+
# TODO for some reason it gives me 4MB for my 4GB drive... and the rounding is off on my 8GB drive
- if info['size']:
+ print(info['fullSize'])
+ if info['fullSize']:
pass
- if info['size'] < 1024:
- name += ' (%d B)' % (info['size'])
- elif info['size'] < 1024 * 1024:
- name += ' (%d KB)' % (info['size'] / 1024)
- elif info['size'] < 1024 * 1024 * 1024:
- name += ' (%d MB)' % (info['size'] / 1024 / 1024)
- elif info['size'] < 1024 * 1024 * 1024 * 1024:
- name += ' (%d GB)' % (info['size'] / 1024 / 1024 / 1024)
+ if info['fullSize'] < gb:
+ name += ' (%.1f B)' % (info['fullSize'])
+ elif info['fullSize'] < gb * gb:
+ name += ' (%.1f KB)' % (info['fullSize'] / gb)
+ elif info['fullSize'] < gb * gb * gb:
+ name += ' (%.1f MB)' % (info['fullSize'] / gb / gb)
+ elif info['fullSize'] < gb * gb * gb * gb:
+ name += ' (%.1f GB)' % (info['fullSize'] / gb / gb / gb)
else:
- name += ' (%d TB)' % (info['size'] / 1024 / 1024 / 1024 / 1024)
+ name += ' (%.1f TB)' % (info['fullSize'] / gb / gb / gb / gb)
self._usbDrives.append(USBDrive(self, name, device))
self.usbDrivesChanged.emit()
--
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