[Nym3-commit] r117 - trunk/nym3/Client

nym3-devel@lists.noreply.org nym3-devel@lists.noreply.org
Sun, 22 Aug 2004 23:07:35 +0200


Author: jr
Date: 2004-08-22 23:07:34 +0200 (Sun, 22 Aug 2004)
New Revision: 117

Added:
   trunk/nym3/Client/Config.py
Modified:
   trunk/nym3/Client/Main.py
   trunk/nym3/Client/User.py
Log:
starting the client


Added: trunk/nym3/Client/Config.py
===================================================================
--- trunk/nym3/Client/Config.py	2004-08-19 09:41:43 UTC (rev 116)
+++ trunk/nym3/Client/Config.py	2004-08-22 21:07:34 UTC (rev 117)
@@ -0,0 +1,6 @@
+DEBUG = False
+
+path = '.'
+
+default_settings = {}
+

Modified: trunk/nym3/Client/Main.py
===================================================================
--- trunk/nym3/Client/Main.py	2004-08-19 09:41:43 UTC (rev 116)
+++ trunk/nym3/Client/Main.py	2004-08-22 21:07:34 UTC (rev 117)
@@ -1,11 +1,11 @@
 import sys
 import os
 import getopt
-import nym3.Client.User
-import nym3.Client.Config
-import nym3.Message
-import nym3.Common
-import nym3.Mail
+import nym3.Client.User as User
+import nym3.Client.Config as Config
+import nym3.Message as Message
+import nym3.Common as Common
+import nym3.Mail as Mail
 
 def processMessage(msg):
     """process incoming control message
@@ -26,14 +26,24 @@
            pass
        elif (com.ct() == 5):
            pass
+
+def setUpAccount(serverName):
+    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__':
-    optlist, pholder = getopt.getopt(sys.argv[1:], 'D:d:m')
+    optlist, pholder = getopt.getopt(sys.argv[1:], 'Ds:m:')
     for o, a in optlist:
         if o == "-D":
             nym3.Client.Config.DEBUG = True
         
     for o, a in optlist:
+        if o == "-s":#setup
+            setUpAccount(a)
         if o == "-m":#control message
 	    processMessage(sys.stdin.read())
 	    sys.exit(0)
+        

Modified: trunk/nym3/Client/User.py
===================================================================
--- trunk/nym3/Client/User.py	2004-08-19 09:41:43 UTC (rev 116)
+++ trunk/nym3/Client/User.py	2004-08-22 21:07:34 UTC (rev 117)
@@ -12,7 +12,7 @@
     def __init__(self, create = 0):
         #TODO what is the criteria determining which account we must load? For the time being we only have a user account
         """0 : load user data throw an error if the account doesn't exist
-        _ : create a new account
+        1 : create a new account throw an error if it already exist
         """
         self.home = Config.path + os.sep
         self.datafile = self.home + 'data'
@@ -23,6 +23,8 @@
         self._lock()
 	try:
 	    f = open(self.datafile, 'r')
+            if create == 1:
+                raise AlreadySuchUser            
         except IOError:
             if create == 0:
                 raise NoSuchUser()
@@ -111,3 +113,5 @@
 	pickle.dump(self.index, f)
 	f.close()
 
+    def generate_keys(self):
+        pass