[Nym3-commit] r40 - trunk

nym3-devel@lists.noreply.org nym3-devel@lists.noreply.org
Thu, 29 Jul 2004 00:47:26 +0200


Author: laurent
Date: 2004-07-29 00:47:23 +0200 (Thu, 29 Jul 2004)
New Revision: 40

Modified:
   trunk/Main.py
   trunk/Message.py
   trunk/User.py
Log:
Define exception used, and use getopt.


Modified: trunk/Main.py
===================================================================
--- trunk/Main.py	2004-07-28 22:28:31 UTC (rev 39)
+++ trunk/Main.py	2004-07-28 22:47:23 UTC (rev 40)
@@ -2,13 +2,14 @@
 
 import sys
 import os
+import getopt
 import User
 import Config
 
 def processIncoming(localpart, msg):
     try:
 	nymuser = User.User(localpart)
-    except NoSuchUser:
+    except User.NoSuchUser:
 	print "No such user"
 	sys.exit(73)
     if nymuser.usage() + len(msg) > nymuser.quota():
@@ -18,3 +19,9 @@
     nymuser.store(msg)
     sys.exit(0)
 
+if __name__ == '__main__':
+    optlist, None = getopt.getopt(sys.argv[1:], 'd:')
+    for o, a in optlist:
+	if o == "-d": # mail delivery
+	    processIncoming(a, sys.stdin.read())
+    

Modified: trunk/Message.py
===================================================================
--- trunk/Message.py	2004-07-28 22:28:31 UTC (rev 39)
+++ trunk/Message.py	2004-07-28 22:47:23 UTC (rev 40)
@@ -45,7 +45,7 @@
 	else:
 		return False
 
-surbLength = 2104        
+surbLength = 2104
 sigLength = 256
 seqNoLength = 20
 msgIdLength = 20
@@ -53,7 +53,7 @@
 class StrReader:
 	"""wraps a string and gives method to read it chunk by chunk"""
         def __init__(self,s):
-	    """initialize by wrapping a string"""	
+	    """initialize by wrapping a string"""
             self.s = s
             self.a = 0
             self.b = 0

Modified: trunk/User.py
===================================================================
--- trunk/User.py	2004-07-28 22:28:31 UTC (rev 39)
+++ trunk/User.py	2004-07-28 22:47:23 UTC (rev 40)
@@ -4,6 +4,8 @@
 import Mail
 import pickle
 
+class NoSuchUser(Exception): pass
+
 class User:
     """Hold user data"""
     def __init__(self, username):