1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2025-08-02 04:21:59 +03:00

examples: Do not use bare except

as it also catches SystemExit, InterruptedError, SyntaxError and such.

Signed-off-by: Philipp Hahn <hahn@univention.de>
This commit is contained in:
Philipp Hahn
2020-04-27 10:29:24 +02:00
committed by Philipp Hahn
parent 06aba185a8
commit 4e22f4de6f
2 changed files with 4 additions and 4 deletions

View File

@ -55,7 +55,7 @@ def stream_callback(stream: libvirt.virStream, events: int, console: Console) ->
try:
assert console.stream
received_data = console.stream.recv(1024)
except:
except Exception:
return
os.write(0, received_data)

View File

@ -80,13 +80,13 @@ def processAgentConnect(dom):
libvirt.VIR_DOMAIN_AFFECT_LIVE)
doc = minidom.parseString(cpus)
ncpus = int(doc.getElementsByTagName('ncpus')[0].getAttribute('count'))
except:
except Exception:
return
try:
dom.setVcpusFlags(ncpus, libvirt.VIR_DOMAIN_AFFECT_LIVE | libvirt.VIR_DOMAIN_VCPU_GUEST)
print("set vcpu count for domain " + dom.name() + " to " + str(ncpus))
except:
except Exception:
print("failed to set vcpu count for domain " + dom.name())
def work():
@ -98,7 +98,7 @@ def work():
if not data.hasConn():
try:
conn = libvirt.open(uri)
except:
except libvirt.libvirtError:
print('Failed to connect to ' + uri + ', retry in ' + str(connectRetryTimeout)) + ' seconds'
time.sleep(connectRetryTimeout)
continue