|
5 | 5 | from yaml import load |
6 | 6 | from Backup import Backup |
7 | 7 |
|
8 | | -__version__ = '#.#.#' |
9 | | -__git_commit__ = 'GIT_COMMIT_HASH' |
| 8 | +__version__ = '#.#.#' |
| 9 | +git_commit = 'GIT_COMMIT_HASH' |
| 10 | +prog_name = os.path.basename(sys.argv[0]) |
10 | 11 |
|
11 | 12 |
|
12 | 13 | def handle_options(parser): |
@@ -51,7 +52,7 @@ def printPythonVersions(): |
51 | 52 | # noinspection PyUnusedLocal |
52 | 53 | def run(): |
53 | 54 | parser = OptionParser() |
54 | | - parser.add_option("--version", dest="version", help="Display version number and exit", action="store_true", default=False) |
| 55 | + parser.add_option("--version", dest="print_version", help="Display version number and exit", action="store_true", default=False) |
55 | 56 | parser.add_option("-v", "--verbose", dest="verbose", help="Increase verbosity", action="store_true", default=False) |
56 | 57 | parser.add_option("-c", "--config", dest="config", help="Use YAML config file as defaults") |
57 | 58 | parser.add_option("-l", "--location", dest="backup_location", help="Directory to save the backup(s) to (required)") |
@@ -81,15 +82,17 @@ def run(): |
81 | 82 | parser.add_option("--no-archive", dest="no_archiver", help="Disable archiving of backups directories post-resolving", action="store_true", default=False) |
82 | 83 | parser.add_option("--no-archive-gzip", dest="no_archiver_gzip", help="Disable gzip compression of archive files", action="store_true", default=False) |
83 | 84 | parser.add_option("--lazy", dest="no_oplog_tailer", help="Disable tailing/resolving of clusterwide oplogs. This makes a shard-consistent, not cluster-consistent backup", action="store_true", default=False) |
84 | | - parser.add_option("--lock-file", dest="lock_file", help="Location of lock file (default: /tmp/%s.lock)" % os.path.basename(sys.argv[0]), default="/tmp/%s.lock" % os.path.basename(sys.argv[0])) |
| 85 | + parser.add_option("--lock-file", dest="lock_file", help="Location of lock file (default: /tmp/%s.lock)" % prog_name, default="/tmp/%s.lock" % prog_name) |
85 | 86 | parser.set_defaults() |
86 | 87 |
|
87 | 88 | options = handle_options(parser) |
88 | 89 |
|
89 | | - if options.version: |
90 | | - binary = os.path.basename(sys.argv[0]) |
91 | | - print "%s version: %s, git commit hash: %s" % (binary, __version__, __git_commit__) |
| 90 | + options.program_name = prog_name |
| 91 | + options.version = __version__ |
| 92 | + options.git_commit = git_commit |
92 | 93 |
|
| 94 | + if options.print_version: |
| 95 | + print "%s version: %s, git commit hash: %s" % (prog_name, __version__, git_commit) |
93 | 96 | if options.verbose: |
94 | 97 | printPythonVersions() |
95 | 98 | sys.exit(0) |
|
0 commit comments