[Zope-Checkins] CVS: Zope/lib/python/Zope/Startup/misc - zpasswd.py:1.4.30.1

Tres Seaver cvs-admin at zope.org
Mon Nov 17 17:10:43 EST 2003


Update of /cvs-repository/Zope/lib/python/Zope/Startup/misc
In directory cvs.zope.org:/tmp/cvs-serv12097/lib/python/Zope/Startup/misc

Modified Files:
      Tag: tseaver-strexp_delenda-branch
	zpasswd.py 
Log Message:



  - Rip string exceptins out by the root.

  - webdav/*:  clean up block statements for readability.

  - XXX:  Redirects are now showing up in the error log object;  need
          to filter!


=== Zope/lib/python/Zope/Startup/misc/zpasswd.py 1.4 => 1.4.30.1 ===
--- Zope/lib/python/Zope/Startup/misc/zpasswd.py:1.4	Tue Mar 18 16:37:49 2003
+++ Zope/lib/python/Zope/Startup/misc/zpasswd.py	Mon Nov 17 17:10:11 2003
@@ -88,6 +88,9 @@
         import do; do.ch(ac_path, user, group)
 
 
+class CommandLineError(Exception):
+    pass
+
 def main(argv):
     short_options = ':u:p:e:d:'
     long_options = ['username=',
@@ -120,12 +123,12 @@
 
     try:
         if len(argv) < 2:
-            raise "CommandLineError"
+            raise CommandLineError, "Not enough arguments!"
 
         optlist, args = getopt.getopt(sys.argv[1:], short_options, long_options)
 
         if len(args) != 1:
-            raise "CommandLineError"
+            raise CommandLineError, "Only one filename allowed!"
 
         access_file = open(args[0], 'w')
 
@@ -147,7 +150,7 @@
 
             # Verify that we got what we need
             if not username or not password:
-                raise "CommandLineError"
+                raise CommandLineError, "Must specify username and password."
 
             access_file.write(username + ':' +
                               generate_passwd(password, encoding) +
@@ -191,10 +194,12 @@
                               generate_passwd(password, encoding) +
                               domains)
 
-    except "CommandLineError":
+    except CommandLineError, v:
         sys.stderr.write(usage)
+        sys.stderr.write("\n\n%s" % v)
         sys.exit(1)
 
 
 # If called from the command line
-if __name__=='__main__': main(sys.argv)
+if __name__=='__main__':
+    main(sys.argv)




More information about the Zope-Checkins mailing list