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
commit 3fba006207
320 changed files with 659 additions and 656 deletions

View file

@ -89,7 +89,7 @@ class Bzr(object):
dest_dirname = os.path.dirname(self.dest)
try:
os.makedirs(dest_dirname)
except:
except Exception:
pass
if self.version.lower() != 'head':
args_list = ["branch", "-r", self.version, self.parent, self.dest]

View file

@ -300,7 +300,7 @@ def head_splitter(headfile, remote, module=None, fail_on_error=False):
f = open(headfile, 'r')
rawdata = f.readline()
f.close()
except:
except Exception:
if fail_on_error and module:
module.fail_json(msg="Unable to read %s" % headfile)
if rawdata:
@ -310,7 +310,7 @@ def head_splitter(headfile, remote, module=None, fail_on_error=False):
newref = refparts[-1]
nrefparts = newref.split('/', 2)
res = nrefparts[-1].rstrip('\n')
except:
except Exception:
if fail_on_error and module:
module.fail_json(msg="Unable to split head from '%s'" % rawdata)
return res
@ -448,7 +448,7 @@ def clone(git_path, module, repo, dest, remote, depth, version, bare,
dest_dirname = os.path.dirname(dest)
try:
os.makedirs(dest_dirname)
except:
except Exception:
pass
cmd = [git_path, 'clone']
@ -1065,7 +1065,7 @@ def main():
module.fail_json(msg="umask must be defined as a quoted octal integer")
try:
umask = int(umask, 8)
except:
except Exception:
module.fail_json(msg="umask must be an octal integer",
details=str(sys.exc_info()[1]))
os.umask(umask)

View file

@ -90,7 +90,7 @@ RETURN = '''# '''
try:
import gitlab
HAS_GITLAB_PACKAGE = True
except:
except Exception:
HAS_GITLAB_PACKAGE = False
from ansible.module_utils.basic import AnsibleModule

View file

@ -143,7 +143,7 @@ RETURN = '''# '''
try:
import gitlab
HAS_GITLAB_PACKAGE = True
except:
except Exception:
HAS_GITLAB_PACKAGE = False
from ansible.module_utils.basic import AnsibleModule

View file

@ -124,7 +124,7 @@ RETURN = '''# '''
try:
import gitlab
HAS_GITLAB_PACKAGE = True
except:
except Exception:
HAS_GITLAB_PACKAGE = False
from ansible.module_utils.basic import AnsibleModule