Update bare exceptions to specify Exception.

This will keep us from accidentally catching program-exiting exceptions
like KeyboardInterupt and SystemExit.
This commit is contained in:
Toshio Kuratomi 2018-09-07 17:59:46 -07:00
parent 5147e792d3
commit 3fba006207
320 changed files with 659 additions and 656 deletions

View file

@ -229,7 +229,7 @@ class LibvirtConnection(object):
else:
try:
state = self.find_entry(entryid).isActive()
except:
except Exception:
return self.module.exit_json(changed=True)
if not state:
return self.module.exit_json(changed=True)
@ -302,7 +302,7 @@ class LibvirtConnection(object):
try:
state = self.find_entry(entryid).isActive()
return ENTRY_STATE_ACTIVE_MAP.get(state, "unknown")
except:
except Exception:
return ENTRY_STATE_ACTIVE_MAP.get("inactive", "unknown")
def get_uuid(self, entryid):
@ -315,7 +315,7 @@ class LibvirtConnection(object):
xml = etree.fromstring(self.find_entry(entryid).XMLDesc(0))
try:
result = xml.xpath('/network/forward')[0].get('mode')
except:
except Exception:
raise ValueError('Forward mode not specified')
return result
@ -323,7 +323,7 @@ class LibvirtConnection(object):
xml = etree.fromstring(self.find_entry(entryid).XMLDesc(0))
try:
result = xml.xpath('/network/domain')[0].get('name')
except:
except Exception:
raise ValueError('Domain not specified')
return result
@ -331,7 +331,7 @@ class LibvirtConnection(object):
xml = etree.fromstring(self.find_entry(entryid).XMLDesc(0))
try:
result = xml.xpath('/network/mac')[0].get('address')
except:
except Exception:
raise ValueError('MAC address not specified')
return result
@ -345,7 +345,7 @@ class LibvirtConnection(object):
else:
try:
return self.find_entry(entryid).autostart()
except:
except Exception:
return self.module.exit_json(changed=True)
def set_autostart(self, entryid, val):
@ -354,7 +354,7 @@ class LibvirtConnection(object):
else:
try:
state = self.find_entry(entryid).autostart()
except:
except Exception:
return self.module.exit_json(changed=True)
if bool(state) != val:
return self.module.exit_json(changed=True)
@ -376,7 +376,7 @@ class LibvirtConnection(object):
else:
try:
self.find_entry(entryid)
except:
except Exception:
return self.module.exit_json(changed=True)