[libblockdev port follow-up][PATCH] Catch GLib.Error where LVM/Crypto/...Error instances were caught

Vratislav Podzimek vpodzime at redhat.com
Wed Feb 4 14:33:20 UTC 2015


GObject introspection raises an exception if GError is set by BlockDev.

Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 blivet/devices/lvm.py | 4 ++--
 blivet/devicetree.py  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py
index 5505bca..0e60eae 100644
--- a/blivet/devices/lvm.py
+++ b/blivet/devices/lvm.py
@@ -24,7 +24,7 @@ from six import add_metaclass
 import abc
 import pprint
 import re
-from gi.repository import BlockDev
+from gi.repository import BlockDev, GLib
 
 # device backend modules
 from ..devicelibs import lvm
@@ -643,7 +643,7 @@ class LVMLogicalVolumeDevice(DMDevice):
 
         try:
             vg_info = BlockDev.lvm_vginfo(self.vg.name)
-        except errors.LVMError as lvmerr:
+        except (errors.LVMError, GLib.GError) as lvmerr:
             log.error("Failed to get free space for the %s VG: %s", self.vg.name, lvmerr)
             # nothing more can be done, we don't know the VG's free space
             return
diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index 78d7067..c751d92 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -1337,7 +1337,7 @@ class DeviceTree(object):
                     device.format.passphrase = passphrase
                     try:
                         device.format.setup()
-                    except CryptoError:
+                    except (CryptoError, GLib.GError):
                         device.format.passphrase = None
                     else:
                         break
-- 
2.1.0



More information about the anaconda-patches mailing list