mirror of
https://gitlab.com/libvirt/libvirt-python.git
synced 2025-07-04 04:59:37 +03:00
examples: Fix connection error handling
libvirt.open*() does not return None but raises an exception Signed-off-by: Philipp Hahn <hahn@univention.de>
This commit is contained in:
committed by
Daniel P. Berrangé
parent
53565fe096
commit
283e2bc693
@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user