mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
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:
parent
5147e792d3
commit
3fba006207
320 changed files with 659 additions and 656 deletions
|
@ -145,7 +145,7 @@ class CapabilitiesModule(object):
|
|||
while opind == -1:
|
||||
opind = cap.find(OPS[i])
|
||||
i += 1
|
||||
except:
|
||||
except Exception:
|
||||
if op_required:
|
||||
self.module.fail_json(msg="Couldn't find operator (one of: %s)" % str(OPS))
|
||||
else:
|
||||
|
|
|
@ -246,7 +246,7 @@ class CronTab(object):
|
|||
except IOError:
|
||||
# cron file does not exist
|
||||
return
|
||||
except:
|
||||
except Exception:
|
||||
raise CronTabError("Unexpected error:", sys.exc_info()[0])
|
||||
else:
|
||||
# using safely quoted shell for now, but this really should be two non-shell calls instead. FIXME
|
||||
|
@ -371,7 +371,7 @@ class CronTab(object):
|
|||
except OSError:
|
||||
# cron file does not exist
|
||||
return False
|
||||
except:
|
||||
except Exception:
|
||||
raise CronTabError("Unexpected error:", sys.exc_info()[0])
|
||||
|
||||
def find_job(self, name, job=None):
|
||||
|
|
|
@ -145,7 +145,7 @@ class CronVar(object):
|
|||
except IOError:
|
||||
# cron file does not exist
|
||||
return
|
||||
except:
|
||||
except Exception:
|
||||
raise CronVarError("Unexpected error:", sys.exc_info()[0])
|
||||
else:
|
||||
# using safely quoted shell for now, but this really should be two non-shell calls instead. FIXME
|
||||
|
@ -200,7 +200,7 @@ class CronVar(object):
|
|||
except OSError:
|
||||
# cron file does not exist
|
||||
return False
|
||||
except:
|
||||
except Exception:
|
||||
raise CronVarError("Unexpected error:", sys.exc_info()[0])
|
||||
|
||||
def parse_for_var(self, line):
|
||||
|
|
|
@ -347,7 +347,7 @@ class DarwinGroup(Group):
|
|||
if highest == 0 or highest == 499:
|
||||
return False
|
||||
return (highest + 1)
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
|
|
|
@ -432,7 +432,7 @@ def remount(module, args):
|
|||
rc = 1
|
||||
else:
|
||||
rc, out, err = module.run_command(cmd)
|
||||
except:
|
||||
except Exception:
|
||||
rc = 1
|
||||
|
||||
msg = ''
|
||||
|
|
|
@ -220,7 +220,7 @@ def main():
|
|||
newline = newline.split('#', 1)[0]
|
||||
try:
|
||||
old_comment = line.split('#', 1)[1]
|
||||
except:
|
||||
except Exception:
|
||||
old_comment = ''
|
||||
|
||||
newline = newline.rstrip()
|
||||
|
@ -299,7 +299,7 @@ def main():
|
|||
|
||||
try:
|
||||
nf.close()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
res_args = dict(
|
||||
|
|
|
@ -307,7 +307,7 @@ def main():
|
|||
module.fail_json(msg="Failed to set boolean %s to %s" % (name, state))
|
||||
try:
|
||||
selinux.security_commit_booleans()
|
||||
except:
|
||||
except Exception:
|
||||
module.fail_json(msg="Failed to commit pending boolean %s value" % name)
|
||||
|
||||
result['changed'] = changed
|
||||
|
|
|
@ -481,7 +481,7 @@ class LinuxService(Service):
|
|||
res = version_re.search(stdout)
|
||||
if res:
|
||||
self.upstart_version = LooseVersion(res.groups()[0])
|
||||
except:
|
||||
except Exception:
|
||||
pass # we'll use the default of 0.0.0
|
||||
|
||||
self.svc_cmd = location['initctl']
|
||||
|
@ -720,7 +720,7 @@ class LinuxService(Service):
|
|||
if self.changed:
|
||||
try:
|
||||
write_to_override_file(override_file_name, override_state)
|
||||
except:
|
||||
except Exception:
|
||||
self.module.fail_json(msg='Could not modify override file')
|
||||
|
||||
return
|
||||
|
@ -1007,7 +1007,7 @@ class FreeBsdService(Service):
|
|||
rc, stdout, stderr = self.execute_command("%s %s %s %s" % (self.svc_cmd, self.name, 'rcvar', self.arguments))
|
||||
try:
|
||||
rcvars = shlex.split(stdout, comments=True)
|
||||
except:
|
||||
except Exception:
|
||||
# TODO: add a warning to the output with the failure
|
||||
pass
|
||||
|
||||
|
|
|
@ -546,7 +546,7 @@ class NosystemdTimezone(Timezone):
|
|||
try:
|
||||
if not filecmp.cmp('/etc/localtime', '/usr/share/zoneinfo/' + planned):
|
||||
return 'n/a'
|
||||
except:
|
||||
except Exception:
|
||||
return 'n/a'
|
||||
else:
|
||||
self.abort('unknown parameter "%s"' % key)
|
||||
|
@ -610,7 +610,7 @@ class SmartOSTimezone(Timezone):
|
|||
m = re.match('^TZ=(.*)$', line.strip())
|
||||
if m:
|
||||
return m.groups()[0]
|
||||
except:
|
||||
except Exception:
|
||||
self.module.fail_json(msg='Failed to read /etc/default/init')
|
||||
else:
|
||||
self.module.fail_json(msg='%s is not a supported option on target platform' % key)
|
||||
|
@ -745,7 +745,7 @@ class BSDTimezone(Timezone):
|
|||
try:
|
||||
if not os.path.isfile(zonefile):
|
||||
self.module.fail_json(msg='%s is not a recognized timezone' % value)
|
||||
except:
|
||||
except Exception:
|
||||
self.module.fail_json(msg='Failed to stat %s' % zonefile)
|
||||
|
||||
# Now (somewhat) atomically update the symlink by creating a new
|
||||
|
@ -759,7 +759,7 @@ class BSDTimezone(Timezone):
|
|||
try:
|
||||
os.symlink(zonefile, new_localtime)
|
||||
os.rename(new_localtime, '/etc/localtime')
|
||||
except:
|
||||
except Exception:
|
||||
os.remove(new_localtime)
|
||||
self.module.fail_json(msg='Could not update /etc/localtime')
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue