1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2025-07-10 00:59:41 +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:
Philipp Hahn
2020-04-20 08:05:00 +02:00
committed by Daniel P. Berrangé
parent 53565fe096
commit 283e2bc693
5 changed files with 15 additions and 11 deletions

View File

@ -32,8 +32,9 @@ if len(sys.argv) != 2:
(name, xmldesc) = read_domain(sys.argv[1])
conn = libvirt.open(None)
if conn is None:
try:
conn = libvirt.open(None)
except libvirt.libvirtError:
print('Failed to open connection to the hypervisor')
sys.exit(1)