diff options
author | Philipp Hahn <hahn@univention.de> | 2020-04-20 08:05:00 +0200 |
---|---|---|
committer | Daniel P. Berrangé <berrange@redhat.com> | 2020-04-20 13:21:55 +0100 |
commit | 283e2bc693746164b22226e14d6fe3ccd38a07bf (patch) | |
tree | 1015159551acea6406a64bcff38b821925807a3e /examples/dominfo.py | |
parent | 53565fe096d9f91cf06ed2100d252a7c62939a71 (diff) | |
download | libvirt-python-283e2bc693746164b22226e14d6fe3ccd38a07bf.tar.gz |
examples: Fix connection error handling
libvirt.open*() does not return None but raises an exception
Signed-off-by: Philipp Hahn <hahn@univention.de>
Diffstat (limited to 'examples/dominfo.py')
-rwxr-xr-x | examples/dominfo.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/examples/dominfo.py b/examples/dominfo.py index 0a39f4c..fcfb8ed 100755 --- a/examples/dominfo.py +++ b/examples/dominfo.py @@ -34,8 +34,9 @@ if len(sys.argv) != 2: name = sys.argv[1] # Connect to libvirt -conn = libvirt.openReadOnly(None) -if conn is None: +try: + conn = libvirt.openReadOnly(None) +except libvirt.libvirtError: print('Failed to open connection to the hypervisor') sys.exit(1) |