Lint: E722 do not use bare 'except'

This commit is contained in:
2020-11-06 18:55:10 -05:00
parent 601ab1a181
commit 63f4f9aed7
17 changed files with 89 additions and 89 deletions

View File

@ -223,7 +223,7 @@ def remove_osd(zk_conn, logger, osd_id, osd_obj):
time.sleep(5)
else:
raise
except:
except Exception:
break
# 3. Stop the OSD process and wait for it to be terminated

View File

@ -337,7 +337,7 @@ class AXFRDaemonInstance(object):
# Set up our SQL cursor
try:
sql_curs = self.sql_conn.cursor()
except:
except Exception:
time.sleep(0.5)
continue

View File

@ -90,7 +90,7 @@ def stopKeepaliveTimer():
try:
update_timer.shutdown()
logger.out('Stopping keepalive timer', state='s')
except:
except Exception:
pass
###############################################################################
@ -100,7 +100,7 @@ def stopKeepaliveTimer():
# Get the config file variable from the environment
try:
pvcnoded_config_file = os.environ['PVCD_CONFIG_FILE']
except:
except Exception:
print('ERROR: The "PVCD_CONFIG_FILE" environment variable must be set before starting pvcnoded.')
exit(1)
@ -176,7 +176,7 @@ def readConfig(pvcnoded_config_file, myhostname):
config_debug = {
'debug': o_config['pvc']['debug']
}
except:
except Exception:
config_debug = {
'debug': False
}
@ -535,7 +535,7 @@ def zk_listener(state):
_zk_conn = kazoo.client.KazooClient(hosts=config['coordinators'])
try:
_zk_conn.start()
except:
except Exception:
del _zk_conn
continue
@ -586,7 +586,7 @@ def cleanup():
logger.out('Waiting for primary migration', state='s')
while this_node.router_state != 'secondary':
time.sleep(0.5)
except:
except Exception:
pass
# Stop keepalive thread
@ -610,7 +610,7 @@ def cleanup():
try:
zk_conn.stop()
zk_conn.close()
except:
except Exception:
pass
logger.out('Terminated pvc daemon', state='s')
@ -829,7 +829,7 @@ def set_maintenance(_maintenance, stat, event=''):
global maintenance
try:
maintenance = bool(strtobool(_maintenance.decode('ascii')))
except:
except Exception:
maintenance = False
# Primary node
@ -1371,7 +1371,7 @@ def collect_vm_stats(queue):
if debug:
try:
logger.out("Failed getting VM information for {}: {}".format(domain.name(), e), state='d', prefix='vm-thread')
except:
except Exception:
pass
continue
@ -1462,7 +1462,7 @@ def node_keepalive():
try:
if zkhandler.readdata(zk_conn, '/upstream_ip') != config['upstream_floating_ip']:
raise
except:
except Exception:
zkhandler.writedata(zk_conn, {'/upstream_ip': config['upstream_floating_ip']})
# Get past state and update if needed
@ -1517,7 +1517,7 @@ def node_keepalive():
this_node.memalloc = vm_thread_queue.get()
this_node.memprov = vm_thread_queue.get()
this_node.vcpualloc = vm_thread_queue.get()
except:
except Exception:
pass
else:
this_node.domains_count = 0
@ -1530,7 +1530,7 @@ def node_keepalive():
ceph_health_colour = ceph_thread_queue.get()
ceph_health = ceph_thread_queue.get()
osds_this_node = ceph_thread_queue.get()
except:
except Exception:
ceph_health_colour = fmt_cyan
ceph_health = 'UNKNOWN'
osds_this_node = '?'
@ -1552,7 +1552,7 @@ def node_keepalive():
'/nodes/{}/runningdomains'.format(this_node.name): ' '.join(this_node.domain_list),
'/nodes/{}/keepalive'.format(this_node.name): str(keepalive_time)
})
except:
except Exception:
logger.out('Failed to set keepalive data', state='e')
return
@ -1623,7 +1623,7 @@ def node_keepalive():
node_daemon_state = zkhandler.readdata(zk_conn, '/nodes/{}/daemonstate'.format(node_name))
node_domain_state = zkhandler.readdata(zk_conn, '/nodes/{}/domainstate'.format(node_name))
node_keepalive = int(zkhandler.readdata(zk_conn, '/nodes/{}/keepalive'.format(node_name)))
except:
except Exception:
node_daemon_state = 'unknown'
node_domain_state = 'unknown'
node_keepalive = 0
@ -1654,5 +1654,5 @@ update_timer = startKeepaliveTimer()
while True:
try:
time.sleep(1)
except:
except Exception:
break

View File

@ -170,7 +170,7 @@ class MetadataAPIInstance(object):
try:
if information.get('ip4_address', None) == source_address:
host_information = information
except:
except Exception:
pass
# Get our real information on the host; now we can start querying about it
@ -188,7 +188,7 @@ class MetadataAPIInstance(object):
if network.get('mac', None) == client_macaddr:
vm_name = vm.get('name')
vm_details = vm
except:
except Exception:
pass
return vm_details

View File

@ -608,7 +608,7 @@ class NodeInstance(object):
try:
lock.acquire(timeout=60) # Don't wait forever and completely block us
self.logger.out('Acquired read lock for synchronization phase G', state='o')
except:
except Exception:
pass
self.logger.out('Releasing read lock for synchronization phase G', state='i')
lock.release()
@ -698,7 +698,7 @@ class NodeInstance(object):
try:
last_node = zkhandler.readdata(self.zk_conn, '/domains/{}/lastnode'.format(dom_uuid))
except:
except Exception:
continue
if last_node != self.name:

View File

@ -112,11 +112,11 @@ class VMInstance(object):
self.last_lastnode = zkhandler.readdata(self.zk_conn, '/domains/{}/lastnode'.format(self.domuuid))
try:
self.pinpolicy = zkhandler.readdata(self.zk_conn, '/domains/{}/pinpolicy'.format(self.domuuid))
except:
except Exception:
self.pinpolicy = "none"
try:
self.migration_method = zkhandler.readdata(self.zk_conn, '/domains/{}/migration_method'.format(self.domuuid))
except:
except Exception:
self.migration_method = 'none'
# These will all be set later
@ -166,7 +166,7 @@ class VMInstance(object):
else:
domain_information = daemon_common.getInformationFromXML(self.zk_conn, self.domuuid)
memory = int(domain_information['memory'])
except:
except Exception:
memory = 0
return memory
@ -174,7 +174,7 @@ class VMInstance(object):
def getvcpus(self):
try:
vcpus = int(self.dom.info()[3])
except:
except Exception:
vcpus = 0
return vcpus
@ -220,7 +220,7 @@ class VMInstance(object):
try:
self.dom = self.lookupByUUID(self.domuuid)
curstate = self.dom.state()[0]
except:
except Exception:
curstate = 'notstart'
if curstate == libvirt.VIR_DOMAIN_RUNNING:
@ -325,7 +325,7 @@ class VMInstance(object):
try:
lvdomstate = self.dom.state()[0]
except:
except Exception:
lvdomstate = None
if lvdomstate != libvirt.VIR_DOMAIN_RUNNING:
@ -435,7 +435,7 @@ class VMInstance(object):
dest_lv_conn = libvirt.open(dest_lv)
if not dest_lv_conn:
raise
except:
except Exception:
self.logger.out('Failed to open connection to {}; aborting live migration.'.format(dest_lv), state='e', prefix='Domain {}'.format(self.domuuid))
return False
@ -643,7 +643,7 @@ class VMInstance(object):
running, reason = self.dom.state()
else:
raise
except:
except Exception:
running = libvirt.VIR_DOMAIN_NOSTATE
self.logger.out('VM state change for "{}": {} {}'.format(self.domuuid, self.state, self.node), state='i')
@ -761,7 +761,7 @@ class VMInstance(object):
dom = lv_conn.lookupByUUID(buuid)
# Fail
except:
except Exception:
dom = None
# After everything

View File

@ -409,7 +409,7 @@ add rule inet filter forward ip6 saddr {netaddr6} counter jump {vxlannic}-out
try:
os.remove(filename)
self.dhcp_server_daemon.signal('hup')
except:
except Exception:
pass
def updateFirewallRules(self):
@ -802,7 +802,7 @@ add rule inet filter forward ip6 saddr {netaddr6} counter jump {vxlannic}-out
try:
os.remove(self.nftables_netconf_filename)
except:
except Exception:
pass
# Reload firewall rules

View File

@ -94,11 +94,11 @@ def run_os_command(command_string, background=False, environment=None, timeout=N
try:
stdout = command_output.stdout.decode('ascii')
except:
except Exception:
stdout = ''
try:
stderr = command_output.stderr.decode('ascii')
except:
except Exception:
stderr = ''
return retcode, stdout, stderr
@ -144,7 +144,7 @@ def findTargetNode(zk_conn, config, logger, dom_uuid):
node_limit = zkhandler.readdata(zk_conn, '/domains/{}/node_limit'.format(dom_uuid)).split(',')
if not any(node_limit):
node_limit = ''
except:
except Exception:
node_limit = ''
zkhandler.writedata(zk_conn, { '/domains/{}/node_limit'.format(dom_uuid): '' })

View File

@ -47,14 +47,14 @@ def get_zookeeper_key():
def get_lease_expiry():
try:
expiry = os.environ['DNSMASQ_LEASE_EXPIRES']
except:
except Exception:
expiry = '0'
return expiry
def get_client_id():
try:
client_id = os.environ['DNSMASQ_CLIENT_ID']
except:
except Exception:
client_id = '*'
return client_id
@ -62,7 +62,7 @@ def connect_zookeeper():
# We expect the environ to contain the config file
try:
pvcnoded_config_file = os.environ['PVCD_CONFIG_FILE']
except:
except Exception:
# Default place
pvcnoded_config_file = '/etc/pvc/pvcnoded.yaml'