[Nym3-commit] r171 - in trunk/nym3: Client Server

laurent at conuropsis.org laurent at conuropsis.org
Mon Apr 4 18:18:56 CEST 2005


Author: laurent
Date: 2005-04-04 18:18:54 +0200 (Mon, 04 Apr 2005)
New Revision: 171

Modified:
   trunk/nym3/Client/Main.py
   trunk/nym3/Server/Main.py
Log:
Temporarily break the client to do it better. Don't even expect this revision
to compile.


Modified: trunk/nym3/Client/Main.py
===================================================================
--- trunk/nym3/Client/Main.py	2005-04-02 21:39:38 UTC (rev 170)
+++ trunk/nym3/Client/Main.py	2005-04-04 16:18:54 UTC (rev 171)
@@ -1,4 +1,5 @@
 # $Id$
+# -*- coding: iso-8859-1 -*-
 #
 # Copyright (c) 2004,2005 Jean-René Reinhard <jr at komite.net>
 # and Laurent Fousse <laurent at komite.net>.
@@ -54,69 +55,51 @@
         elif (com.ct() == 5):
             pass
 
-def setupAccount(serverName):
+def setupAccount(ui, serverName = None, usernamelist = None,
+		 emailAddress = None, nickname = None):
     """Tries to setup a new account on the given server"""
-    try:
-        nymUser = User.User(1)
-    except User.AlreadySuchUser:
-        return
-    nymUser.generate_keys() #TODO how do we stock private key? protect it with a passphrase?
-
-
-
-if __name__ == '__main__':
-    #the one where we set up the parser
-    Config.DEBUG = False
-    def setDebug(option, opt, value, parser):
-        nym3.Client.Config.DEBUG = True
-    def setUser(option, opt, value, parser):
-        try:
-            nymUser = User.User(idTag = value, create = 0)
-        except User.NoSuchUser:
-            print "the nym account %s does not exist" % value
-            sys.exit(2)
-        
-    def setUserTagged(option, opt, value, parser):
-        try:
-            T = User.Tag()
-            nymUser = User.User(idTag = T[value], create = 0)
-            del T
-        except KeyError:
-            print "No account correspond to the tag %s" % value
-            sys.exit(2)
-        except User.NoSuchUser:
-            print "the nym account %s does not exist" % value
-            sys.exit(2)
+    if not nickname:
+	nickname = ui.prompt("How do you want to name this account")
+    while True: # chose a suitable account name
+	account = None
+	try:
+	    account = User.Account(nickname)
+	except User.AlreadySuchAccount:
+	    ui.display("This account name is already in use")
+	    nickname = ui.prompt("New account name")
+	if account: break
+    if not serverName:
+	serverName = ui.prompt("At which server do you want to register"
+			       " this account")
+    if not usernamelist:
+	ui.display("You need a username for this account.")
+	usernamelist = ui.prompt("Enter several choices, one per line,"
+				 " finish by a blank line")
+    if not emailAddress:
+	emailAddress = ui.prompt("What is the default email address for "
+				 "returning messages")
     
-
-    def setDefaultUser():
-        setUser(None, "", Config.defaultUser, None)
-
-    def myParseArgs(p, l):
-        ret = p.parse_args(l)
-        if nymUser == None:
-            setDefaultUser()
-        return ret
+	
+def main(args):
+    if args[1] == "create":
+	parser = OptionParser()
+	parser.add_option("-s", "--server", action = "store", dest = "server")
     
-    parser = OptionParser()
 
+if __name__ == '__main__':
+    main(sys.argv)
+    sys.exit(0)
+
     #the one when we determine the user account
     nymUser = None
     
     #TODO put here options common to every command
-    parser.add_option("-D", "--debug", action = "callback", 
+    parser.add_option("-d", "--debug", action = "", 
 		      callback = setDebug, help = "output message on stdout "
 		      "instead of sending them through mixminion")
     userOption = make_option("-u", "--user", action = "callback", 
 			     callback = setUser, type = "string",
 			     help = "determine the user account to be used")
-    # ", Client.Config.DefaultUser by default")
-    # how helpful is that supposed to be to the user?
-    taggedUserOption = make_option("-t", "--tag", action = "callback", 
-				   callback = setUserTagged,
-				   type = "string", help = "determine the "
-				   "user account to be used from a tag")
-    
     if len(sys.argv) < 2:
 	print "Usage: nymclient <command> [arguments]"
 	sys.exit(1)

Modified: trunk/nym3/Server/Main.py
===================================================================
--- trunk/nym3/Server/Main.py	2005-04-02 21:39:38 UTC (rev 170)
+++ trunk/nym3/Server/Main.py	2005-04-04 16:18:54 UTC (rev 171)
@@ -38,7 +38,6 @@
 lifeCycle = Common.lifeCycle
 """The life cycle of a mail received by the server for a nym""" 
 
-
 def processIncoming(localpart, msg):
     """Process incoming mail from the MTA
     - identifies the nym the mail is addressed to
@@ -70,14 +69,14 @@
     sr = Message.StrReader(msg)
     try:
 	h = sr.readHeader()
-        if(h.nym == ""):
+        if (h.nym == ""):
             comList = sr.readCommandCToSList()
             try:
-                if(len(comList) != 3):
+                if (len(comList) != 3):
                     raise MyException()
 	        #this may be an account setup message
-	        #we suppose there is a exactly 1 Create Command in the message, 1 Newpk, and 1 surb
-	        #more will raise an error
+		#we suppose there is a exactly 1 Create Command in the message,
+		# 1 Newpk, and 1 surb. more will raise an error
 
                 nymUser = None
 	        #phase 1 we look for the command create
@@ -91,7 +90,7 @@
                                 pass
                             if(nymUser != None):
                                 break
-                        if(nymUser == None):
+                        if (nymUser == None):
                             #TODO send an Error message to the client when surbs become available?
                             #for the time being just ignore
                             print "All nyms proposed in the list were already attributed"
@@ -223,4 +222,3 @@
 	if o == "-m":
 	    processMessage(sys.stdin.read())
 	    sys.exit(0)
-



More information about the Nym3-commit mailing list