Fix two more cases in examples as
libvirt.open*() does not return None but raises an exception
Fixes: 283e2bc693746164b22226e14d6fe3ccd38a07bf
Signed-off-by: Philipp Hahn <hahn(a)univention.de>
---
examples/dhcpleases.py | 5 +++--
examples/domipaddrs.py | 5 +++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/examples/dhcpleases.py b/examples/dhcpleases.py
index f394541..6f80fd5 100755
--- a/examples/dhcpleases.py
+++ b/examples/dhcpleases.py
@@ -22,8 +22,9 @@ else:
usage()
sys.exit(2)
-conn = libvirt.open(uri)
-if conn == None:
+try:
+ conn = libvirt.open(uri)
+except libvirt.libvirtError:
print("Unable to open connection to libvirt")
sys.exit(1)
diff --git a/examples/domipaddrs.py b/examples/domipaddrs.py
index bda308c..e893995 100755
--- a/examples/domipaddrs.py
+++ b/examples/domipaddrs.py
@@ -21,8 +21,9 @@ else:
usage()
sys.exit(2)
-conn = libvirt.open(uri)
-if conn == None:
+try:
+ conn = libvirt.open(uri)
+except libvirt.libvirtError:
print "Unable to open connection to libvirt"
sys.exit(1)
--
2.20.1