[PATCH 1/2] Mark storage errors for translations and show them translated (#877658)
Vratislav Podzimek
vpodzime at redhat.com
Fri Dec 21 10:37:18 UTC 2012
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
pyanaconda/storage/partitioning.py | 45 +++++++++++++++++++-------------------
pyanaconda/ui/gui/spokes/custom.py | 2 +-
2 files changed, 24 insertions(+), 23 deletions(-)
diff --git a/pyanaconda/storage/partitioning.py b/pyanaconda/storage/partitioning.py
index 8e784ee..089cb8e 100644
--- a/pyanaconda/storage/partitioning.py
+++ b/pyanaconda/storage/partitioning.py
@@ -37,6 +37,7 @@ from formats import getFormat
import gettext
_ = lambda x: gettext.ldgettext("anaconda", x)
+N_ = lambda x: x
import logging
log = logging.getLogger("storage")
@@ -288,7 +289,7 @@ def doAutoPartition(storage, data):
return
if not storage.partitioned:
- raise NoDisksError("No usable disks selected")
+ raise NoDisksError(N_("No usable disks selected"))
disks = _getCandidateDisks(storage)
devs = _scheduleImplicitPartitions(storage, disks)
@@ -296,8 +297,8 @@ def doAutoPartition(storage, data):
log.debug("devs: %s" % devs)
if disks == []:
- raise NotEnoughFreeSpaceError("Not enough free space on disks for "
- "automatic partitioning")
+ raise NotEnoughFreeSpaceError(N_("Not enough free space on disks for "
+ "automatic partitioning"))
_schedulePartitions(storage, disks)
@@ -626,7 +627,7 @@ def addPartition(disklabel, free, part_type, size):
end = disklabel.endAlignment.alignNearest(free, end)
log.debug("adjusted length from %d to %d" % (length, end - start + 1))
if start > end:
- raise PartitioningError("unable to allocate aligned partition")
+ raise PartitioningError(N_("unable to allocate aligned partition"))
new_geom = parted.Geometry(device=disklabel.partedDevice,
start=start,
@@ -634,7 +635,7 @@ def addPartition(disklabel, free, part_type, size):
max_length = disklabel.partedDisk.maxPartitionLength
if max_length and new_geom.length > max_length:
- raise PartitioningError("requested size exceeds maximum allowed")
+ raise PartitioningError(N_("requested size exceeds maximum allowed"))
# create the partition and add it to the disk
partition = parted.Partition(disk=disklabel.partedDisk,
@@ -725,7 +726,7 @@ def doPartitioning(storage):
"""
if not hasattr(storage.platform, "diskLabelTypes"):
- raise StorageError("can't allocate partitions without platform data")
+ raise StorageError(N_("can't allocate partitions without platform data"))
disks = storage.partitioned
if storage.config.exclusiveDisks:
@@ -736,7 +737,7 @@ def doPartitioning(storage):
disk.setup()
except DeviceError as (msg, name):
log.error("failed to set up disk %s: %s" % (name, msg))
- raise PartitioningError("disk %s inaccessible" % disk.name)
+ raise PartitioningError(N_("disk %s inaccessible" % disk.name))
partitions = storage.partitions[:]
for part in storage.partitions:
@@ -790,14 +791,14 @@ def doPartitioning(storage):
for part in [p for p in storage.partitions if not p.exists]:
problem = part.checkSize()
if problem < 0:
- raise PartitioningError("partition is too small for %s formatting "
- "(allowable size is %d MB to %d MB)"
+ raise PartitioningError(N_("partition is too small for %s formatting "
+ "(allowable size is %d MB to %d MB)")
% (part.format.name,
part.format.minSize,
part.format.maxSize))
elif problem > 0:
- raise PartitioningError("partition is too large for %s formatting "
- "(allowable size is %d MB to %d MB)"
+ raise PartitioningError(N_("partition is too large for %s formatting "
+ "(allowable size is %d MB to %d MB)")
% (part.format.name,
part.format.minSize,
part.format.maxSize))
@@ -1038,7 +1039,7 @@ def allocatePartitions(storage, disks, partitions, freespace):
break
if free is None:
- raise PartitioningError("not enough free space on disks")
+ raise PartitioningError(N_("not enough free space on disks"))
_disk = use_disk
disklabel = _disk.format
@@ -1059,8 +1060,8 @@ def allocatePartitions(storage, disks, partitions, freespace):
boot=boot,
grow=_part.req_grow)
if not free:
- raise PartitioningError("not enough free space after "
- "creating extended partition")
+ raise PartitioningError(N_("not enough free space after "
+ "creating extended partition"))
partition = addPartition(disklabel, free, part_type, _part.req_size)
log.debug("created partition %s of %dMB and added it to %s" %
@@ -1231,7 +1232,7 @@ class Chunk(object):
if request.growth < amount:
log.error("tried to reclaim %d from request with %d of growth"
% (amount, request.growth))
- raise ValueError("cannot reclaim more than request has grown")
+ raise ValueError(N_("cannot reclaim more than request has grown"))
request.growth -= amount
self.pool += amount
@@ -1411,8 +1412,8 @@ class DiskChunk(Chunk):
def addRequest(self, req):
""" Add a Request to this chunk. """
if not isinstance(req, PartitionRequest):
- raise ValueError("DiskChunk requests must be of type "
- "PartitionRequest")
+ raise ValueError(N_("DiskChunk requests must be of type "
+ "PartitionRequest"))
if not self.requests:
# when adding the first request to the chunk, adjust the pool
@@ -1424,8 +1425,8 @@ class DiskChunk(Chunk):
# start sector is beyond the maximum allowed end sector, we
# cannot continue
log.error("chunk start sector is beyond disklabel maximum")
- raise PartitioningError("partitions allocated outside "
- "disklabel limits")
+ raise PartitioningError(N_("partitions allocated outside "
+ "disklabel limits"))
new_pool = chunk_end - self.geometry.start + 1
if new_pool != self.pool:
@@ -1504,8 +1505,8 @@ class VGChunk(Chunk):
def addRequest(self, req):
""" Add a Request to this chunk. """
if not isinstance(req, LVRequest):
- raise ValueError("VGChunk requests must be of type "
- "LVRequest")
+ raise ValueError(N_("VGChunk requests must be of type "
+ "LVRequest"))
super(VGChunk, self).addRequest(req)
@@ -1933,7 +1934,7 @@ def growLVM(storage):
if total_free < 0:
# by now we have allocated the PVs so if there isn't enough
# space in the VG we have a real problem
- raise PartitioningError("not enough space for LVM requests")
+ raise PartitioningError(N_("not enough space for LVM requests"))
elif not total_free:
log.debug("vg %s has no free space" % vg.name)
continue
diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index f2ab156..6839b72 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -2448,7 +2448,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
dlg = Gtk.MessageDialog(flags=Gtk.DialogFlags.MODAL,
message_type=Gtk.MessageType.ERROR,
buttons=Gtk.ButtonsType.CLOSE,
- message_format=str(self._error))
+ message_format=_(str(self._error)))
dlg.set_decorated(False)
with enlightbox(self.window, dlg):
--
1.7.11.7
More information about the anaconda-patches
mailing list