summaryrefslogtreecommitdiffstats
path: root/storage/formats/disklabel.py
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2009-09-02 14:00:31 +0200
committerHans de Goede <hdegoede@redhat.com>2009-09-02 19:28:52 +0200
commit2b3c4a423d5ef8e190ac3e38e62b00174bc08c12 (patch)
treebe7dd17b191cd75df011e687d8684599b318c727 /storage/formats/disklabel.py
parentef63316f047549a6e17212a2ac42d7a0ec8e6e03 (diff)
downloadanaconda-2b3c4a423d5ef8e190ac3e38e62b00174bc08c12.tar.gz
anaconda-2b3c4a423d5ef8e190ac3e38e62b00174bc08c12.tar.xz
anaconda-2b3c4a423d5ef8e190ac3e38e62b00174bc08c12.zip
Do not traceback on an usb cardreader with no card present
This patch fixes 2 things, which together fix tracebacks on an usb cardreader with no card present 1) Add a check to format.disklabel() for no media being present 2) _ped.DeviceException was changed to _ped.IOException for no media present errors in current pyparted
Diffstat (limited to 'storage/formats/disklabel.py')
-rw-r--r--storage/formats/disklabel.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/storage/formats/disklabel.py b/storage/formats/disklabel.py
index 8a653f0ff..a387c56bd 100644
--- a/storage/formats/disklabel.py
+++ b/storage/formats/disklabel.py
@@ -63,7 +63,7 @@ class DiskLabel(DeviceFormat):
self._partedDisk = None
self._origPartedDisk = None
- if self.device:
+ if self.partedDevice:
# set up the parted objects and raise exception on failure
self._origPartedDisk = self.partedDisk.duplicate()
@@ -119,7 +119,14 @@ class DiskLabel(DeviceFormat):
def partedDevice(self):
if not self._partedDevice and self.device and \
os.path.exists(self.device):
- self._partedDevice = parted.Device(path=self.device)
+ # We aren't guaranteed to be able to get a device. In
+ # particular, built-in USB flash readers show up as devices but
+ # do not always have any media present, so parted won't be able
+ # to find a device.
+ try:
+ self._partedDevice = parted.Device(path=self.device)
+ except _ped.IOException:
+ pass
return self._partedDevice