Skip to content

Commit 10a822c

Browse files
Moving 'compression' and 'threads' up to tar-only
1 parent 327d07b commit 10a822c

File tree

10 files changed

+32
-22
lines changed

10 files changed

+32
-22
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
bin
22
build
33
rpmbuild
4+
pex
45
*.pyc
56
.idea

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ rpm: clean
3434
rpmbuild -D "_topdir $(PWD)/rpmbuild" -D "version $(VERSION)" -bb rpmbuild/SPECS/$(NAME).spec
3535

3636
clean:
37-
rm -rf bin build rpmbuild $(NAME).egg-info 2>/dev/null
37+
rm -rf bin build rpmbuild $(NAME).egg-info pex 2>/dev/null

mongodb_consistent_backup/Archive/Archive.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ def __init__(self, config, backup_dir):
1313

1414
def init(self):
1515
archive_method = self.config.archive.method
16-
if not archive_method or archive_method is "none":
16+
if not archive_method or archive_method.lower() is "none":
1717
logging.info("Archiving disabled, skipping")
1818
else:
1919
config_vars = ""
20+
method = archive_method.lower()
2021
for key in self.config.archive:
2122
config_vars += "%s=%s," % (key, self.config.archive[key])
22-
logging.info("Using archiving method: %s (options: %s)" % (archive_method, str(config_vars[:-1])))
23+
logging.info("Using archiving method: %s (options: %s)" % (method, str(config_vars[:-1])))
2324
try:
24-
self._archiver = globals()[archive_method.capitalize()](
25+
self._archiver = globals()[method.capitalize()](
2526
self.config,
2627
self.backup_dir
2728
)

mongodb_consistent_backup/Archive/Tar/Tar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class Tar:
2222
def __init__(self, config, backup_base_dir):
2323
self.config = config
2424
self.backup_base_dir = backup_base_dir
25-
self.compression = self.config.archive.compression
26-
self.thread_count = self.config.archive.threads
25+
self.compression = self.config.archive.tar.compression
26+
self.thread_count = self.config.archive.tar.threads
2727
self.verbose = self.config.verbose
2828
self.binary = "tar"
2929

mongodb_consistent_backup/Archive/Tar/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33

44
def config(parser):
5-
parser.add_argument("--archive.compression", dest="archive.compression",
5+
parser.add_argument("--archive.tar.compression", dest="archive.tar.compression",
66
help="Archiver compression method (default: gzip)", default='gzip', choices=['gzip', 'none'])
7+
parser.add_argument("--archive.tar.threads", dest="archive.tar.threads",
8+
help="Number of threads to use in archive phase (default: 1-per-CPU)", default=0, type=int)
79
return parser

mongodb_consistent_backup/Archive/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33

44
def config(parser):
55
parser.add_argument("--archive.method", dest="archive.method", help="Archiver method (default: tar)", default='tar', choices=['tar','none'])
6-
parser.add_argument("--archive.threads", dest="archive.threads", help="Number of threads to use in archive phase (default: 1-per-CPU)", default=0, type=int)
76
return parser

mongodb_consistent_backup/Backup/Backup.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,19 @@ def __init__(self, config, backup_dir, secondaries, config_server=None):
1515

1616
def init(self):
1717
backup_method = self.config.backup.method
18-
if not backup_method or backup_method is "none":
18+
if not backup_method or backup_method.lower() is "none":
1919
raise Exception, 'Must specify a backup method!', None
20-
logging.info("Using backup method: %s" % backup_method)
20+
method = backup_method.lower()
21+
logging.info("Using backup method: %s" % method)
2122
try:
22-
self._method = globals()[backup_method.capitalize()](
23+
self._method = globals()[method.capitalize()](
2324
self.config,
2425
self.backup_dir,
2526
self.secondaries,
2627
self.config_server
2728
)
2829
except Exception, e:
29-
raise Exception, "Problem performing %s! Error: %s" % (backup_method, e), None
30+
raise Exception, "Problem performing %s! Error: %s" % (method, e), None
3031

3132
def is_compressed(self):
3233
if self._method:

mongodb_consistent_backup/Notify/Notify.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22

33
class Notify:
44
def __init__(self, config):
5-
self.config = config
5+
self.config = config
6+
67
self._notifier = None
78
self.init()
89

910
def init(self):
1011
notify_method = self.config.notify.method
11-
if not notify_method or notify_method is "none":
12+
if not notify_method or notify_method.lower() is "none":
1213
logging.info("Notifying disabled, skipping")
1314
else:
14-
logging.info("Using notify method: %s" % notify_method)
15+
method = notify_method.lower()
16+
logging.info("Using notify method: %s" % method)
1517
try:
16-
self._notifier = globals()[notify_method.capitalize()](self.config)
18+
self._notifier = globals()[method.capitalize()](self.config)
1719
except Exception, e:
1820
raise e
1921

mongodb_consistent_backup/Upload/Upload.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,22 @@ def __init__(self, config, base_dir, backup_dir):
1414

1515
def init(self):
1616
upload_method = self.config.upload.method
17-
if not upload_method or upload_method is "none":
17+
if not upload_method or upload_method.lower() is "none":
1818
logging.info("Uploading disabled, skipping")
1919
else:
2020
#TODO Remove this line and move to S3 Lib for checking
2121
# if self.config.upload.method == "s3" and self.config.upload.s3.bucket_name and self.config.upload.s3.bucket_prefix and self.config.upload.s3.access_key and self.config.upload.s3.secret_key:
2222

23-
logging.info("Using upload method: %s" % upload_method)
23+
method = upload_method.lower()
24+
logging.info("Using upload method: %s" % method)
2425
try:
25-
self._uploader = globals()[upload_method.capitalize()](
26+
self._uploader = globals()[method.capitalize()](
2627
self.config,
2728
self.base_dir,
2829
self.backup_dir
2930
)
3031
except Exception, e:
31-
raise Exception, "Problem settings up %s Uploader Error: %s" % (self.config.upload.method, e), None
32+
raise Exception, "Problem settings up %s Uploader Error: %s" % (method, e), None
3233

3334
def upload(self):
3435
if self._uploader:

scripts/build.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ rootdir=$(readlink -f $(dirname $0)/..)
88
srcdir=${rootdir}/${mod_name}
99
bindir=${rootdir}/bin
1010
builddir=${rootdir}/build
11+
cachedir=${rootdir}/cache
12+
pexcachedir=${cachedir}/cache/pex
1113
venvdir=${builddir}/venv
1214
output_file=${bindir}/${name}
1315
require_file=${builddir}/requirements.txt
@@ -85,15 +87,16 @@ if [ -d ${srcdir} ]; then
8587
exit 1
8688
fi
8789
source ${venvdir}/bin/activate
88-
90+
8991
${venvdir}/bin/python2.7 ${venvdir}/bin/pip install pex requests
9092
if [ $? -gt 0 ]; then
9193
echo "Failed to install pex utility for building!"
9294
exit 1
9395
fi
9496

9597
[ ! -d ${bindir} ] && mkdir -p ${bindir}
96-
${venvdir}/bin/python2.7 ${venvdir}/bin/pex --disable-cache -o ${output_file} -m ${mod_name} -r ${require_file} ${builddir}
98+
[ ! -d ${pexcachedir} ] && mkdir -p ${pexcachedir}
99+
${venvdir}/bin/python2.7 ${venvdir}/bin/pex --cache-root ${pexcachedir} -o ${output_file} -m ${mod_name} -r ${require_file} ${builddir}
97100
if [ $? -lt 1 ] && [ -x ${output_file} ]; then
98101
echo "pex executable written to '$output_file'"
99102
else

0 commit comments

Comments
 (0)