Skip to content

Commit

Permalink
Refactor: Resolve flake8 E722 bare except
Browse files Browse the repository at this point in the history
It is considered bad practice to use a bare except as this kind
of except statement can have untended consequences such as disabling
ctrl+c interrupts. At the vary least we should use Exception however
a more specific one would be better. This PR uses the general Exception
to resolve the linter which we can add more specific ones later when
we can appropriately unit test the code.

Signed-off-by: Thanh Ha <[email protected]>
Change-Id: I9afcff49f34326d279a63ce972d12f9aa72f18e2
  • Loading branch information
zxiiro committed Oct 5, 2021
1 parent 8c6774a commit 533e3cb
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lftools/api/endpoints/gerrit.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def sanity_check(self, fqdn, gerrit_project, **kwargs):
log.info(access_str)
try:
result = self.get(access_str)[1]
except:
except Exception:
log.info("Not found {}".format(access_str))
exit(1)
log.info("found {} {}".format(access_str, mylist))
Expand Down
2 changes: 1 addition & 1 deletion lftools/cli/infofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def create_info_file(ctx, gerrit_url, gerrit_project, directory, empty, tsc_appr

try:
owner = result["local"]["refs/*"]["permissions"]["owner"]["rules"]
except:
except Exception:
print("ERROR: Check project config, no owner set!")

for x in owner:
Expand Down
2 changes: 1 addition & 1 deletion lftools/cli/ldap_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def main(groups):
user_info = ldap_query(l, ldap_user_base, user, ["uid", "cn", "mail"])
try:
print("%s,%s" % (group_name, user_to_csv(user_info)))
except:
except Exception:
eprint("Error parsing user: %s" % user)
continue
ldap_disconnect(l)
Expand Down
2 changes: 1 addition & 1 deletion lftools/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def _get_node_from_xml(xml_data, tag_name):
try:
dom1 = parseString(xml_data)
childnode = dom1.getElementsByTagName(tag_name)[0]
except:
except Exception:
_log_error_and_exit("Received bad XML, can not find tag {}".format(tag_name), xml_data)
return childnode.firstChild.data

Expand Down

0 comments on commit 533e3cb

Please sign in to comment.