Skip to content

Commit 863a431

Browse files
authored
Merge pull request #198 from timvaillancourt/flake8_fixes_v0
Flake8 fixes
2 parents 34818a2 + 5613318 commit 863a431

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+217
-204
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ install: bin/mongodb-consistent-backup
2222
install -m 0644 LICENSE $(SHAREDIR)/$(NAME)/LICENSE
2323
install -m 0644 README.rst $(SHAREDIR)/$(NAME)/README.rst
2424

25+
flake8:
26+
# Ignore long-lines and space-aligned = and : for now
27+
flake8 --ignore E221,E241,E501 $(PWD)/$(NAME)
28+
2529
uninstall:
2630
rm -f $(BINDIR)/mongodb-consistent-backup
2731
rm -rf $(SHAREDIR)/$(NAME)

README.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ Roadmap
218218
- Documentation for running under Docker with persistent volumes
219219
- Python unit tests
220220

221+
Submitting Code
222+
~~~~~~~~~~~~~~~
223+
224+
- Submitted code must pass Python `'flake8' <https://pypi.python.org/pypi/flake8>`__ checks. Run *'make flake8'* to test.
225+
- To make review easier, pull requests must address and solve one problem at a time.
226+
221227
Links
222228
~~~~~
223229

mongodb_consistent_backup/Archive/Archive.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from mongodb_consistent_backup.Archive.Tar import Tar
2-
from mongodb_consistent_backup.Archive.Zbackup import Zbackup
31
from mongodb_consistent_backup.Pipeline import Stage
42

53

mongodb_consistent_backup/Archive/Tar/Tar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from types import MethodType
88

99
from TarThread import TarThread
10-
from mongodb_consistent_backup.Common import parse_method
1110
from mongodb_consistent_backup.Errors import Error, OperationError
1211
from mongodb_consistent_backup.Pipeline import Task
1312

@@ -19,6 +18,7 @@ def _reduce_method(m):
1918
else:
2019
return getattr, (m.im_self, m.im_func.func_name)
2120

21+
2222
pickle(MethodType, _reduce_method)
2323

2424

mongodb_consistent_backup/Archive/Tar/TarThread.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@ def run(self):
2828
if os.path.isdir(self.backup_dir):
2929
if not os.path.isfile(self.output_file):
3030
try:
31-
backup_base_dir = os.path.dirname(self.backup_dir)
32-
backup_base_name = os.path.basename(self.backup_dir)
33-
34-
log_msg = "Archiving directory: %s" % self.backup_dir
35-
cmd_flags = ["-C", backup_base_dir, "-cf", self.output_file, "--remove-files", backup_base_name]
36-
37-
if self.do_gzip():
38-
log_msg = "Archiving and compressing directory: %s" % self.backup_dir
39-
cmd_flags = ["-C", backup_base_dir, "-czf", self.output_file, "--remove-files", backup_base_name]
40-
41-
logging.info(log_msg)
42-
self.running = True
43-
self._command = LocalCommand(self.binary, cmd_flags, self.verbose)
44-
self.exit_code = self._command.run()
31+
backup_base_dir = os.path.dirname(self.backup_dir)
32+
backup_base_name = os.path.basename(self.backup_dir)
33+
34+
log_msg = "Archiving directory: %s" % self.backup_dir
35+
cmd_flags = ["-C", backup_base_dir, "-cf", self.output_file, "--remove-files", backup_base_name]
36+
37+
if self.do_gzip():
38+
log_msg = "Archiving and compressing directory: %s" % self.backup_dir
39+
cmd_flags = ["-C", backup_base_dir, "-czf", self.output_file, "--remove-files", backup_base_name]
40+
41+
logging.info(log_msg)
42+
self.running = True
43+
self._command = LocalCommand(self.binary, cmd_flags, self.verbose)
44+
self.exit_code = self._command.run()
4545
except Exception, e:
4646
logging.fatal("Failed archiving file: %s! Error: %s" % (self.output_file, e))
4747
finally:
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from Tar import Tar
1+
from Tar import Tar # NOQA
22

33

44
def config(parser):
55
parser.add_argument("--archive.tar.compression", dest="archive.tar.compression",
66
help="Tar archiver compression method (default: gzip)", default='gzip', choices=['gzip', 'none'])
7-
parser.add_argument("--archive.tar.threads", dest="archive.tar.threads",
7+
parser.add_argument("--archive.tar.threads", dest="archive.tar.threads",
88
help="Number of Tar archiver threads to use (default: 1-per-CPU)", default=0, type=int)
99
return parser

mongodb_consistent_backup/Archive/Zbackup/Zbackup.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,20 @@ def version(self):
9595
return None
9696
except Exception, e:
9797
raise OperationError("Could not gather ZBackup version: %s" % e)
98-
98+
9999
def has_zbackup(self):
100100
if self.version():
101-
return True
101+
return True
102102
return False
103103

104104
def close(self, exit_code=None, frame=None):
105105
del exit_code
106106
del frame
107107
if not self.stopped:
108-
if self._zbackup and self._zbackup.poll() == None:
108+
if self._zbackup and self._zbackup.poll() is None:
109109
logging.debug("Stopping running ZBackup command")
110110
self._zbackup.terminate()
111-
if self._tar and self._tar.poll() == None:
111+
if self._tar and self._tar.poll() is None:
112112
logging.debug("Stopping running ZBackup tar command")
113113
self._tar.terminate()
114114
self.stopped = True
@@ -131,12 +131,12 @@ def wait(self):
131131
self.poll()
132132
if tar_done:
133133
self._zbackup.communicate()
134-
if self._zbackup.poll() != None:
134+
if self._zbackup.poll() is not None:
135135
logging.info("ZBackup completed successfully with exit code: %i" % self._zbackup.returncode)
136136
if self._zbackup.returncode != 0:
137137
raise OperationError("ZBackup exited with code: %i!" % self._zbackup.returncode)
138138
break
139-
elif self._tar.poll() != None:
139+
elif self._tar.poll() is not None:
140140
if self._tar.returncode == 0:
141141
logging.debug("ZBackup tar command completed successfully with exit code: %i" % self._tar.returncode)
142142
tar_done = True
@@ -160,9 +160,9 @@ def run(self):
160160
lock = Lock(self.zbackup_lock)
161161
lock.acquire()
162162
try:
163-
logging.info("Starting ZBackup version: %s (options: compression=%s, encryption=%s, threads=%i, cache_mb=%i)" %
164-
(self.version(), self.compression(), self.encrypted, self.threads(), self.zbackup_cache_mb)
165-
)
163+
logging.info("Starting ZBackup version: %s (options: compression=%s, encryption=%s, threads=%i, cache_mb=%i)" % (
164+
self.version(), self.compression(), self.encrypted, self.threads(), self.zbackup_cache_mb
165+
))
166166
self.running = True
167167
try:
168168
for sub_dir in os.listdir(self.backup_dir):

mongodb_consistent_backup/Archive/Zbackup/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from Zbackup import Zbackup
1+
from Zbackup import Zbackup # NOQA
22

33

44
def config(parser):
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from Archive import Archive
1+
from Archive import Archive # NOQA
22

33

44
def config(parser):
5-
parser.add_argument("--archive.method", dest="archive.method", help="Archiver method (default: tar)", default='tar', choices=['tar','zbackup','none'])
5+
parser.add_argument("--archive.method", dest="archive.method", help="Archiver method (default: tar)", default='tar', choices=['tar', 'zbackup', 'none'])
66
return parser

mongodb_consistent_backup/Backup/Backup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from mongodb_consistent_backup.Backup.Mongodump import Mongodump
1+
from mongodb_consistent_backup.Backup.Mongodump import Mongodump # NOQA
22
from mongodb_consistent_backup.Pipeline import Stage
33

44

0 commit comments

Comments
 (0)