Skip to content

Commit 6d22b8e

Browse files
authored
Merge pull request #238 from timvaillancourt/flake8_E722_fix
Fix new flake8 'E722 do not use bare except' errors
2 parents 004dfcc + db04c72 commit 6d22b8e

File tree

8 files changed

+11
-11
lines changed

8 files changed

+11
-11
lines changed

mongodb_consistent_backup/Backup/Mongodump/Mongodump.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def close(self):
187187
thread.terminate()
188188
try:
189189
self.timer.stop(self.timer_name)
190-
except:
190+
except Exception:
191191
pass
192192
logging.info("Stopped all mongodump threads")
193193
self.stopped = True

mongodb_consistent_backup/Backup/Mongodump/MongodumpThread.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def parse_mongodump_line(self, line):
8585
elif is_datetime(line):
8686
return None
8787
return "%s:\t%s" % (self.uri, line)
88-
except:
88+
except Exception:
8989
return None
9090

9191
def is_password_prompt(self, line):

mongodb_consistent_backup/Common/Config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def parse_config_bool(item):
1616
if item.rstrip().lower() is "true":
1717
return True
1818
return False
19-
except:
19+
except Exception:
2020
return False
2121

2222

@@ -121,7 +121,7 @@ def check_required(self):
121121
for key in required:
122122
try:
123123
self._get(key)
124-
except:
124+
except Exception:
125125
raise mongodb_consistent_backup.Errors.OperationError(
126126
'Field "%s" (config file field: "%s.%s") must be set via command-line or config file!' % (
127127
key,
@@ -160,5 +160,5 @@ def __getattr__(self, key):
160160
try:
161161
return self._config.get(key)
162162
# TODO-timv What can we do to make this better?
163-
except:
163+
except Exception:
164164
return None

mongodb_consistent_backup/Common/MongoUri.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def get(self, incr_idx=False):
7171
if incr_idx:
7272
self.addr_idx += 1
7373
return addr
74-
except:
74+
except Exception:
7575
pass
7676
return None
7777

mongodb_consistent_backup/Common/Util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def is_datetime(string):
1717
try:
1818
parser.parse(string)
1919
return True
20-
except:
20+
except Exception:
2121
return False
2222

2323

mongodb_consistent_backup/Main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def cleanup_and_exit(self, code, frame):
169169
submodule = getattr(self, submodule_name)
170170
if submodule:
171171
submodule.close()
172-
except:
172+
except Exception:
173173
continue
174174

175175
if self.manager:

mongodb_consistent_backup/Oplog/Tailer/Tailer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def stop(self, kill=False, sleep_secs=3):
9898
# get current optime of replset primary to use a stop position
9999
try:
100100
timestamp = replset.primary_optime(True, True)
101-
except:
101+
except Exception:
102102
logging.warning("Could not get current optime from PRIMARY! Using now as a stop time")
103103
timestamp = Timestamp(int(time()), 0)
104104

mongodb_consistent_backup/State.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __init__(self, base_dir, config, filename="meta.bson", state_version=1, meta
2626
# try normal mkdir first, fallback to recursive mkdir if there is an exception
2727
try:
2828
os.mkdir(self.state_dir)
29-
except:
29+
except Exception:
3030
try:
3131
os.makedirs(self.state_dir)
3232
except Exception, e:
@@ -157,7 +157,7 @@ def load_backups(self):
157157
self.backups[subdir] = self.load(True, state_file)
158158
if self.backups[subdir]["completed"]:
159159
self.completed_backups += 1
160-
except:
160+
except Exception:
161161
continue
162162
logging.info("Found %i existing completed backups for set" % self.completed_backups)
163163
return self.backups

0 commit comments

Comments
 (0)