diff options
author | Philipp Hahn <hahn@univention.de> | 2020-04-27 10:08:08 +0200 |
---|---|---|
committer | Michal Privoznik <mprivozn@redhat.com> | 2020-04-27 11:16:21 +0200 |
commit | 4d99e8443c15447da3b0fe9a63642966e02e508c (patch) | |
tree | 045178f28ca054164f8aef2219e9f4cf931db803 /examples | |
parent | 4252e827e0c4d2c9e231a94865df2da1bc06fc09 (diff) | |
download | libvirt-python-4d99e8443c15447da3b0fe9a63642966e02e508c.tar.gz |
examples: Fix connection error handling 2
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@univention.de>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/dhcpleases.py | 5 | ||||
-rwxr-xr-x | 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) |