---
pyanaconda/packaging/dnfpayload.py | 2 +-
pyanaconda/packaging/yumpayload.py | 2 +-
pyanaconda/ui/gui/spokes/custom.py | 36 ++++++++++++++++---------------
pyanaconda/ui/gui/spokes/lib/accordion.py | 2 +-
pyanaconda/ui/gui/spokes/lib/resize.py | 6 +++---
pyanaconda/ui/gui/spokes/storage.py | 6 +++---
pyanaconda/ui/lib/disks.py | 6 +++---
pyanaconda/ui/lib/space.py | 2 +-
pyanaconda/ui/tui/spokes/storage.py | 2 +-
9 files changed, 33 insertions(+), 31 deletions(-)
diff --git a/pyanaconda/packaging/dnfpayload.py b/pyanaconda/packaging/dnfpayload.py
index 9de7ceb..4f3343c 100644
--- a/pyanaconda/packaging/dnfpayload.py
+++ b/pyanaconda/packaging/dnfpayload.py
@@ -248,7 +248,7 @@ class DNFPayload(packaging.PackagePayload):
def spaceRequired(self):
transaction = self._base.transaction
if transaction is None:
- return Size(spec="3000 MB")
+ return Size(en_spec="3000 MB")
size = sum(tsi.installed.installsize for tsi in transaction)
# add 35% to account for the fact that the above method is laughably
diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py
index c82fc94..d658b39 100644
--- a/pyanaconda/packaging/yumpayload.py
+++ b/pyanaconda/packaging/yumpayload.py
@@ -193,7 +193,7 @@ class YumPayload(PackagePayload):
# This value comes from a default install of the x86_64 Fedora 18. It
# is meant as a best first guess only. Once package metadata is
# available we can use that as a better value.
- self._space_required = Size(spec="3000 MB")
+ self._space_required = Size(en_spec="3000 MB")
self._groups = None
self._packages = []
diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index 1950a5b..8cb430a 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -31,6 +31,7 @@
from contextlib import contextmanager
import re
+import unicodedata
from pykickstart.constants import CLEARPART_TYPE_NONE, AUTOPART_TYPE_PLAIN,
AUTOPART_TYPE_BTRFS, AUTOPART_TYPE_LVM, AUTOPART_TYPE_LVM_THINP
@@ -148,20 +149,21 @@ partition_only_format_types = ["efi", "macefi",
"prepboot", "biosboot",
"appleboot"]
def size_from_entry(entry):
- size_text = entry.get_text().strip()
-
- # if no unit was specified, default to MB
- if not re.search(r'[A-Za-z]+$', size_text):
- size_text += "MB"
+ size_text = entry.get_text().decode("utf-8").strip()
try:
- size = Size(spec=size_text)
+ # if no unit was specified, default to MB. Assume that a string
+ # ending with any kind of a letter has a unit suffix.
+ if unicodedata.category(size_text[-1]).startswith("L"):
+ size = Size(spec=size_text)
+ else:
+ size = Size(en_spec="%sMB" % size_text)
except (SizeParamsError, SizeNotPositiveError, ValueError):
return None
else:
# Minimium size for ui-created partitions is 1MB.
- if size.convertTo(spec="mb") < 1:
- size = Size(spec="1mb")
+ if size.convertTo(en_spec="mb") < 1:
+ size = Size(en_spec="1mb")
return size
@@ -352,7 +354,7 @@ class DisksDialog(GUIObject):
# populate the store
for disk in self._disks:
self._store.append([disk.description,
- str(Size(spec="%dMB" % disk.size)),
+ str(Size(en_spec="%dMB" % disk.size)),
str(free[disk.name][0]),
disk.serial,
disk.id])
@@ -436,7 +438,7 @@ class ContainerDialog(GUIObject):
# populate the store
for disk in self._disks:
self._store.append([disk.description,
- str(Size(spec="%dMB" % disk.size)),
+ str(Size(en_spec="%dMB" % disk.size)),
str(free[disk.name][0]),
disk.serial,
disk.id])
@@ -462,7 +464,7 @@ class ContainerDialog(GUIObject):
self._raidStoreFilter.refilter()
self._populate_raid()
- size = Size(spec="%d mb" % self.size)
+ size = Size(en_spec="%d mb" % self.size)
self._sizeEntry.set_text(size.humanReadable(max_places=None))
if self.size_policy == SIZE_POLICY_AUTO:
self._sizeCombo.set_active(0)
@@ -538,7 +540,7 @@ class ContainerDialog(GUIObject):
elif idx == 2:
size = size_from_entry(self._sizeEntry)
if size:
- size = int(size.convertTo(spec="MB"))
+ size = int(size.convertTo(en_spec="MB"))
elif size is None:
size = SIZE_POLICY_MAX
@@ -832,7 +834,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
for disk in self._clearpartDevices:
totalSpace += disk.size
- return Size(spec="%f MB" % totalSpace)
+ return Size(en_spec="%f MB" % totalSpace)
def _updateSpaceDisplay(self):
# Set up the free space/available space displays in the bottom left.
@@ -1145,7 +1147,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
old_size = device.size
size = size_from_entry(self._sizeEntry)
if size:
- size = int(size.convertTo(spec="MB"))
+ size = int(size.convertTo(en_spec="MB"))
changed_size = ((use_dev.resizable or not use_dev.exists) and
size != int(old_size))
log.debug("old size: %s", old_size)
@@ -1697,7 +1699,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
else:
self._labelEntry.set_tooltip_text(_("This file system does not support
labels."))
- self._sizeEntry.set_text(Size(spec="%d MB" %
device.size).humanReadable(max_places=None))
+ self._sizeEntry.set_text(Size(en_spec="%d MB" %
device.size).humanReadable(max_places=None))
self._reformatCheckbox.set_active(not device.format.exists)
fancy_set_sensitive(self._reformatCheckbox, not device.protected and
@@ -1945,7 +1947,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
log.debug("requested size = %s ; available space = %s", dialog.size,
self._free_space)
# if no size was entered, request as much of the free space as possible
- if dialog.size is not None and dialog.size.convertTo(spec="mb") <
1:
+ if dialog.size is not None and dialog.size.convertTo(en_spec="mb") <
1:
size = None
else:
size = dialog.size
@@ -1989,7 +1991,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
disks = self._clearpartDevices
if size is not None:
- size = float(size.convertTo(spec="mb"))
+ size = float(size.convertTo(en_spec="mb"))
self.clear_errors()
diff --git a/pyanaconda/ui/gui/spokes/lib/accordion.py
b/pyanaconda/ui/gui/spokes/lib/accordion.py
index 5990332..6a5067a 100644
--- a/pyanaconda/ui/gui/spokes/lib/accordion.py
+++ b/pyanaconda/ui/gui/spokes/lib/accordion.py
@@ -58,7 +58,7 @@ def selectorFromDevice(device, selector=None, mountpoint=""):
else:
mp = _("Unknown")
- size = Size(spec="%f MB" % device.size)
+ size = Size(en_spec="%f MB" % device.size)
if not selector:
selector = MountpointSelector(device.name, str(size).upper(), mp)
diff --git a/pyanaconda/ui/gui/spokes/lib/resize.py
b/pyanaconda/ui/gui/spokes/lib/resize.py
index f1b6905..d69626a 100644
--- a/pyanaconda/ui/gui/spokes/lib/resize.py
+++ b/pyanaconda/ui/gui/spokes/lib/resize.py
@@ -173,7 +173,7 @@ class ResizeDialog(GUIObject):
# And then add another uneditable line that lists how much space is
# already free in the disk.
diskFree = free_space[disk.name][0]
- converted = diskFree.convertTo(spec="mb")
+ converted = diskFree.convertTo(en_spec="mb")
if int(converted):
self._diskStore.append(itr, [disk.id,
_("""<span
foreground='grey' style='italic'>Free
space</span>"""),
@@ -375,7 +375,7 @@ class ResizeDialog(GUIObject):
self._diskStore.foreach(self._sumReclaimableSpace, None)
self._update_labels(selectedReclaimable=self._selectedReclaimableSpace)
- self._update_reclaim_button(Size(spec="%f MB" %
self._selectedReclaimableSpace))
+ self._update_reclaim_button(Size(en_spec="%f MB" %
self._selectedReclaimableSpace))
self._update_action_buttons(selectedRow)
def _scheduleActions(self, model, path, itr, *args):
@@ -458,7 +458,7 @@ class ResizeDialog(GUIObject):
self._update_labels(selectedReclaimable=self._selectedReclaimableSpace)
# And then the reclaim button, in case they've made enough space.
- self._update_reclaim_button(Size(spec="%f MB" %
self._selectedReclaimableSpace))
+ self._update_reclaim_button(Size(en_spec="%f MB" %
self._selectedReclaimableSpace))
def resize_slider_format(self, scale, value):
# This makes the value displayed under the slider prettier than just a
diff --git a/pyanaconda/ui/gui/spokes/storage.py b/pyanaconda/ui/gui/spokes/storage.py
index 01cf18e..3573a8f 100644
--- a/pyanaconda/ui/gui/spokes/storage.py
+++ b/pyanaconda/ui/gui/spokes/storage.py
@@ -711,7 +711,7 @@ class StorageSpoke(NormalSpoke, StorageChecker):
summary = (P_("%(count)d disk selected; %(capacity)s capacity; %(free)s
free",
"%(count)d disks selected; %(capacity)s capacity; %(free)s
free",
count) % {"count" : count,
- "capacity" : str(Size(spec="%f MB" %
capacity)),
+ "capacity" : str(Size(en_spec="%f MB"
% capacity)),
"free" : free})
summary_label = self.builder.get_object("summary_label")
summary_label.set_text(summary)
@@ -814,7 +814,7 @@ class StorageSpoke(NormalSpoke, StorageChecker):
# show the installation options dialog
disks = [d for d in self.disks if d.name in self.selected_disks]
- disks_size = sum(Size(spec="%f MB" % d.size) for d in disks)
+ disks_size = sum(Size(en_spec="%f MB" % d.size) for d in disks)
# No disks selected? The user wants to back out of the storage spoke.
if not disks:
@@ -842,7 +842,7 @@ class StorageSpoke(NormalSpoke, StorageChecker):
auto_swap = Size(bytes=0)
for autoreq in self.storage.autoPartitionRequests:
if autoreq.fstype == "swap":
- auto_swap += Size(spec="%d MB" % autoreq.size)
+ auto_swap += Size(en_spec="%d MB" % autoreq.size)
log.debug("disk free: %s fs free: %s sw needs: %s auto swap: %s",
disk_free, fs_free, required_space, auto_swap)
diff --git a/pyanaconda/ui/lib/disks.py b/pyanaconda/ui/lib/disks.py
index 4dcd701..32389e0 100644
--- a/pyanaconda/ui/lib/disks.py
+++ b/pyanaconda/ui/lib/disks.py
@@ -75,8 +75,8 @@ def isLocalDisk(disk):
def size_str(mb):
if isinstance(mb, Size):
- spec = str(mb)
+ size = mb
else:
- spec = "%f mb" % mb
+ size = Size(en_spec="%f mb" % mb)
- return str(Size(spec=spec)).upper()
+ return str(size).upper()
diff --git a/pyanaconda/ui/lib/space.py b/pyanaconda/ui/lib/space.py
index 0c252d1..8a45022 100644
--- a/pyanaconda/ui/lib/space.py
+++ b/pyanaconda/ui/lib/space.py
@@ -71,7 +71,7 @@ class FileSystemSpaceChecker(object):
in the info bar at the bottom of a Hub.
"""
self.reset()
- free = Size(spec="%.2f MB" % self.storage.fileSystemFreeSpace)
+ free = Size(en_spec="%.2f MB" % self.storage.fileSystemFreeSpace)
needed = self.payload.spaceRequired
log.info("fs space: %s needed: %s", free, needed)
self.success = (free >= needed)
diff --git a/pyanaconda/ui/tui/spokes/storage.py b/pyanaconda/ui/tui/spokes/storage.py
index 0936b5f..edf149e 100644
--- a/pyanaconda/ui/tui/spokes/storage.py
+++ b/pyanaconda/ui/tui/spokes/storage.py
@@ -155,7 +155,7 @@ class StorageSpoke(NormalTUISpoke):
summary = (P_(("%d disk selected; %s capacity; %s free ..."),
("%d disks selected; %s capacity; %s free ..."),
- count) % (count, str(Size(spec="%f MB" % capacity)),
free))
+ count) % (count, str(Size(en_spec="%f MB" % capacity)),
free))
if len(self.disks) == 0:
summary = _("No disks detected. Please shut down the computer, connect
at least one disk, and restart to complete installation.")
--
1.8.3.1