Commit 8a332bfa authored by Tim Peters's avatar Tim Peters

die() and call sites: Simplified. In case of getopt error, the code

tried to print the module docstring, but in an unreachable line.  In
case of more than 2 positional args, the code died with a mysterious
"unpack tuple of wrong size" exception; check for the correct # of args
directly instead.  Print all error msgs to stderr instead of stdout.
parent cf69728b
...@@ -64,12 +64,11 @@ Important: The ZODB package must be importable. You may need to adjust ...@@ -64,12 +64,11 @@ Important: The ZODB package must be importable. You may need to adjust
import sys, os import sys, os
if __name__ == '__main__' and len(sys.argv) < 3: def die(mess='', show_docstring=False):
print __doc__ % sys.argv[0] if mess:
print >> sys.stderr, mess + '\n'
def die(mess=''): if show_docstring:
if not mess: mess="%s: %s" % sys.exc_info()[:2] print >> sys.stderr, __doc__ % sys.argv[0]
print mess+'\n'
sys.exit(1) sys.exit(1)
try: import ZODB try: import ZODB
...@@ -222,10 +221,13 @@ def progress(p): ...@@ -222,10 +221,13 @@ def progress(p):
def main(): def main():
try: try:
opts, (inp, outp) = getopt.getopt(sys.argv[1:], "fv:pP:") opts, args = getopt.getopt(sys.argv[1:], "fv:pP:")
except getopt.error: except getopt.error, msg:
die() die(str(msg), show_docstring=True)
print __doc__ % sys.argv[0]
if len(args) != 2:
die("two positional arguments required", show_docstring=True)
inp, outp = args
force = partial = verbose = 0 force = partial = verbose = 0
pack = None pack = None
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment