[Zope-Checkins] SVN: Zope/trunk/ Collector #1473: zpasswd.py can now accept --username without --password

Chris Withers chris at simplistix.co.uk
Fri Sep 24 20:51:41 EDT 2004


Log message for revision 27684:
  Collector #1473: zpasswd.py can now accept --username without --password
  


Changed:
  U   Zope/trunk/doc/CHANGES.txt
  U   Zope/trunk/utilities/zpasswd.py


-=-
Modified: Zope/trunk/doc/CHANGES.txt
===================================================================
--- Zope/trunk/doc/CHANGES.txt	2004-09-24 21:17:51 UTC (rev 27683)
+++ Zope/trunk/doc/CHANGES.txt	2004-09-25 00:51:41 UTC (rev 27684)
@@ -156,6 +156,9 @@
        is now installed into the 'bin' folder.
 
     Bugs fixed
+ 
+     - Collector #1473: zpasswd.py can now accept --username 
+       without --password
 
      - Collector #1491: talgettext.py did not create a proper header
        for the generated .pot file if multiple pagetemplate files

Modified: Zope/trunk/utilities/zpasswd.py
===================================================================
--- Zope/trunk/utilities/zpasswd.py	2004-09-24 21:17:51 UTC (rev 27683)
+++ Zope/trunk/utilities/zpasswd.py	2004-09-25 00:51:41 UTC (rev 27684)
@@ -99,6 +99,16 @@
 
         import do; do.ch(ac_path, user, group)
 
+def get_password():
+    while 1:
+        password = getpass.getpass("Password: ")
+        verify = getpass.getpass("Verify password: ")
+        if verify == password:
+            return password
+        else:
+            password = verify = ''
+            print "Password mismatch, please try again..."
+
 def write_inituser(home, user='', group=''):
     ac_path=os.path.join(home, 'inituser')
     if not os.path.exists(ac_path):
@@ -163,8 +173,8 @@
 
     if opts:
         # There were some command line args, so verify
-        if username is None or password is None:
-            usage(1, '-u and -p are required')
+        if username is not None and password is None:
+            password = get_password()
     else:
         # No command line args, so prompt
         while 1:
@@ -172,16 +182,9 @@
             if username != '':
                 break
 
+        password = get_password()
+        
         while 1:
-            password = getpass.getpass("Password: ")
-            verify = getpass.getpass("Verify password: ")
-            if verify == password:
-                break
-            else:
-                password = verify = ''
-                print "Password mismatch, please try again..."
-
-        while 1:
             print """
 Please choose a format from:
 



More information about the Zope-Checkins mailing list