mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10: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
|
@ -357,7 +357,7 @@ class PolicyRcD(object):
|
|||
if self.backup_dir:
|
||||
try:
|
||||
shutil.move('/usr/sbin/policy-rc.d', self.backup_dir)
|
||||
except:
|
||||
except Exception:
|
||||
self.m.fail_json(msg="Fail to move /usr/sbin/policy-rc.d to %s" % self.backup_dir)
|
||||
|
||||
# we write /usr/sbin/policy-rc.d so it always exit with code policy_rc_d
|
||||
|
@ -366,7 +366,7 @@ class PolicyRcD(object):
|
|||
policy_rc_d.write('#!/bin/sh\nexit %d\n' % self.m.params['policy_rc_d'])
|
||||
|
||||
os.chmod('/usr/sbin/policy-rc.d', 0o0755)
|
||||
except:
|
||||
except Exception:
|
||||
self.m.fail_json(msg="Failed to create or chmod /usr/sbin/policy-rc.d")
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
|
@ -385,7 +385,7 @@ class PolicyRcD(object):
|
|||
shutil.move(os.path.join(self.backup_dir, 'policy-rc.d'),
|
||||
'/usr/sbin/policy-rc.d')
|
||||
os.rmdir(self.tmpdir_name)
|
||||
except:
|
||||
except Exception:
|
||||
self.m.fail_json(msg="Fail to move back %s to /usr/sbin/policy-rc.d"
|
||||
% os.path.join(self.backup_dir, 'policy-rc.d'))
|
||||
else:
|
||||
|
@ -393,7 +393,7 @@ class PolicyRcD(object):
|
|||
# we just remove the file
|
||||
try:
|
||||
os.remove('/usr/sbin/policy-rc.d')
|
||||
except:
|
||||
except Exception:
|
||||
self.m.fail_json(msg="Fail to remove /usr/sbin/policy-rc.d (after package manipulation)")
|
||||
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ def codex_fresh(codex, module):
|
|||
|
||||
try:
|
||||
mtime = os.stat(lastupdate_path).st_mtime
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
lastupdate_ts = datetime.datetime.fromtimestamp(mtime)
|
||||
|
@ -472,7 +472,7 @@ def manage_spells(module):
|
|||
|
||||
try:
|
||||
queue_size = os.stat(sorcery_queue).st_size
|
||||
except:
|
||||
except Exception:
|
||||
module.fail_json(msg="failed to read the update queue")
|
||||
|
||||
if queue_size != 0:
|
||||
|
|
|
@ -240,7 +240,7 @@ def split_name_version(name):
|
|||
if version is None:
|
||||
version = ''
|
||||
return prefix, name, version
|
||||
except:
|
||||
except Exception:
|
||||
return prefix, name, ''
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue