[Twisted-Python] correction to patch to tap.ftp

Amir Bakhtiar ab at pobox.com
Wed Feb 26 13:45:26 MST 2003


Got confused by the interplay of optParameters and opt_ methods.
Here is a simplified version of my earlier patch.

This patch allows username and password pairs to be defined.
e.g. mktap ftp -uamir -wfoo
       mktap ftp -uamir:glyph -wfoo:bar

-A-


--- ftp.py 2003-02-26 12:41:27.000000000 -0800
+++ ftp.orig.py 2003-02-26 11:31:15.000000000 -0800
@@ -33,16 +33,14 @@
     optParameters = [
         ["port", "p", "2121",                 "set the port number"],
         ["root", "r", "/usr/local/ftp",       "define the root of the
ftp-site."],
-        ["useranonymous", "", "anonymous",    "Name of the anonymous
user."],
-        ["username", "u", "twisted","set login username. colon separate for
multiple."],
-        ["password", "w", "twisted","set password. colon separate for
multiple."]
+        ["useranonymous", "", "anonymous",    "Name of the anonymous
user."]
     ]
     optFlags = [["anonymous", "a","allow anonymous logins"],
                 ["thirdparty", "3", "allow third-party connections"],
                 ["otp", "","activate One-Time Passwords"]]

     longdesc = ''
-
+

 def addUser(factory, username, password):
     factory.userdict[username] = {}
@@ -62,15 +60,8 @@
     t.otp = config.opts['otp']
     t.userdict = {}

-    if config.opts['username']:
-        # Adding specified users
-        unames = config.opts['username'].split(':')
-        pwords = config.opts['password'].split(':')
-        for u, p in zip(unames, pwords):
-            addUser(t, u, p)
-    else:
-        # Adding a default user
-        addUser(t, "twisted", "twisted")
+    # adding a default user
+    addUser(t, "twisted", "twisted")

     try:
         portno = int(config.opts['port'])







More information about the Twisted-Python mailing list