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

@@ -131,7 +131,7 @@ def main():
# here we attempt to load those stats,
try:
stats = json.loads(stats_raw)
except:
except Exception:
module.fail_json(msg='Could not parse Riak stats.')
node_name = stats['nodename']

View File

@@ -111,7 +111,7 @@ def db_create(conn, cursor, db):
def db_delete(conn, cursor, db):
try:
cursor.execute("ALTER DATABASE [%s] SET single_user WITH ROLLBACK IMMEDIATE" % db)
except:
except Exception:
pass
cursor.execute("DROP DATABASE [%s]" % db)
return not db_exists(conn, cursor, db)

View File

@@ -139,7 +139,7 @@ def stop_slave(cursor):
try:
cursor.execute("STOP SLAVE")
stopped = True
except:
except Exception:
stopped = False
return stopped
@@ -148,7 +148,7 @@ def reset_slave(cursor):
try:
cursor.execute("RESET SLAVE")
reset = True
except:
except Exception:
reset = False
return reset
@@ -157,7 +157,7 @@ def reset_slave_all(cursor):
try:
cursor.execute("RESET SLAVE ALL")
reset = True
except:
except Exception:
reset = False
return reset
@@ -166,7 +166,7 @@ def start_slave(cursor):
try:
cursor.execute("START SLAVE")
started = True
except:
except Exception:
started = False
return started

View File

@@ -588,7 +588,7 @@ def main():
try:
cursor = mysql_connect(module, 'root', '', config_file, ssl_cert, ssl_key, ssl_ca, db,
connect_timeout=connect_timeout)
except:
except Exception:
pass
if not cursor:

View File

@@ -181,7 +181,7 @@ def lang_drop(cursor, lang, cascade):
cursor.execute("DROP LANGUAGE \"%s\" CASCADE" % lang)
else:
cursor.execute("DROP LANGUAGE \"%s\"" % lang)
except:
except Exception:
cursor.execute("ROLLBACK TO SAVEPOINT ansible_pgsql_lang_drop")
cursor.execute("RELEASE SAVEPOINT ansible_pgsql_lang_drop")
return False

View File

@@ -466,7 +466,7 @@ def user_delete(cursor, user):
cursor.execute("SAVEPOINT ansible_pgsql_user_delete")
try:
cursor.execute("DROP USER %s" % pg_quote_identifier(user, 'role'))
except:
except Exception:
cursor.execute("ROLLBACK TO SAVEPOINT ansible_pgsql_user_delete")
cursor.execute("RELEASE SAVEPOINT ansible_pgsql_user_delete")
return False