[Zodb-checkins] CVS: ZODB/src/ZODB - fsrecover.py:1.19

Tim Peters tim.one at comcast.net
Mon May 3 12:12:55 EDT 2004


Update of /cvs-repository/ZODB/src/ZODB
In directory cvs.zope.org:/tmp/cvs-serv4157/src/ZODB

Modified Files:
	fsrecover.py 
Log Message:
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.


=== ZODB/src/ZODB/fsrecover.py 1.18 => 1.19 ===
--- ZODB/src/ZODB/fsrecover.py:1.18	Mon May  3 12:04:32 2004
+++ ZODB/src/ZODB/fsrecover.py	Mon May  3 12:12:51 2004
@@ -64,12 +64,11 @@
 
 import sys, os
 
-if __name__ == '__main__' and len(sys.argv) < 3:
-    print __doc__ % sys.argv[0]
-
-def die(mess=''):
-    if not mess: mess="%s: %s" % sys.exc_info()[:2]
-    print mess+'\n'
+def die(mess='', show_docstring=False):
+    if mess:
+        print >> sys.stderr, mess + '\n'
+    if show_docstring:
+        print >> sys.stderr, __doc__ % sys.argv[0]
     sys.exit(1)
 
 try: import ZODB
@@ -222,10 +221,13 @@
 
 def main():
     try:
-        opts, (inp, outp) = getopt.getopt(sys.argv[1:], "fv:pP:")
-    except getopt.error:
-        die()
-        print __doc__ % sys.argv[0]
+        opts, args = getopt.getopt(sys.argv[1:], "fv:pP:")
+    except getopt.error, msg:
+        die(str(msg), show_docstring=True)
+
+    if len(args) != 2:
+        die("two positional arguments required", show_docstring=True)
+    inp, outp = args
 
     force = partial = verbose = 0
     pack = None




More information about the Zodb-checkins mailing list