[blivet:master 1/3] Add sectorSize property to catch and handle missing partedDevice (#1095329)

mulhern amulhern at redhat.com
Thu May 8 19:35:43 UTC 2014


Resolves: fed#1095329

Signed-off-by: mulhern <amulhern at redhat.com>
---
 blivet/formats/disklabel.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/blivet/formats/disklabel.py b/blivet/formats/disklabel.py
index e06c39f..d563c75 100644
--- a/blivet/formats/disklabel.py
+++ b/blivet/formats/disklabel.py
@@ -105,7 +105,7 @@ class DiskLabel(DeviceFormat):
               "  origPartedDisk = %(orig_disk)r\n"
               "  partedDevice = %(dev)s\n" %
               {"type": self.labelType, "count": len(self.partitions),
-               "sectorSize": self.partedDevice.sectorSize,
+               "sectorSize": self.sectorSize,
                "offset": self.alignment.offset,
                "grain": self.alignment.grainSize,
                "disk": self.partedDisk, "orig_disk": self._origPartedDisk,
@@ -124,7 +124,7 @@ class DiskLabel(DeviceFormat):
 
         d.update({"labelType": self.labelType,
                   "partitionCount": len(self.partitions),
-                  "sectorSize": self.partedDevice.sectorSize,
+                  "sectorSize": self.sectorSize,
                   "offset": self.alignment.offset,
                   "grainSize": self.alignment.grainSize})
         return d
@@ -213,6 +213,14 @@ class DiskLabel(DeviceFormat):
         return lt
 
     @property
+    def sectorSize(self):
+        try:
+            return self.partedDevice.sectorSize
+        except AttributeError:
+            log_exception_info()
+            return None
+
+    @property
     def name(self):
         return "%s (%s)" % (_(self._name), self.labelType.upper())
 
-- 
1.8.3.1



More information about the anaconda-patches mailing list