CVS: tmda/bin ChangeLog,1.279,1.280 tmda-check-address,1.15,1.16

Timothy Legant <[email protected]>
Newsgroups gmane.mail.spam.tmda.cvs
Message-ID <[email protected]>
Update of /cvsroot/tmda/tmda/bin
In directory sc8-pr-cvs1:/tmp/cvs-serv5594/bin

Modified Files:
	ChangeLog tmda-check-address 
Log Message:
tmda-check-address: Imported Defaults.py.  Fixed some unusual code
that apparently doesn't work in later versions of Python (different
exceptions are raised than were caught).  Added new function
formattime().

Address.py: Fixed ConfirmAddress, removed formatting code from
DatedAddress.timestamp().



Index: ChangeLog
===================================================================
RCS file: /cvsroot/tmda/tmda/bin/ChangeLog,v
retrieving revision 1.279
retrieving revision 1.280
diff -u -r1.279 -r1.280
--- ChangeLog	18 Jun 2003 03:49:53 -0000	1.279
+++ ChangeLog	25 Jun 2003 05:29:13 -0000	1.280
@@ -1,3 +1,11 @@
+2003-06-25  Tim Legant  <[email protected]>
+
+	* tmda-check-address (main): Imported Defaults.py.  Fixed some
+	unusual code that apparently doesn't work in later versions of
+	Python (different exceptions are raised than were caught).
+
+	* (formattime): New function.
+
 2003-06-17  Tim Legant  <[email protected]>
 
 	* tmda-rfilter (setvuserhomedir): New function.  Called during

Index: tmda-check-address
===================================================================
RCS file: /cvsroot/tmda/tmda/bin/tmda-check-address,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- tmda-check-address	27 Apr 2003 07:58:18 -0000	1.15
+++ tmda-check-address	25 Jun 2003 05:29:13 -0000	1.16
@@ -94,13 +94,24 @@
     elif opt in ('-l', '--localtime'):
         localtime = 1
 
+from TMDA import Defaults
 from TMDA import Address
 
+def formattime(timestamp):
+    if localtime:
+        timetuple = time.localtime(int(timestamp))
+        tzstr = ' %Z'
+    else:
+        timetuple = time.gmtime(int(timestamp))
+        tzstr = ' UTC'
+    return time.strftime('%c' + tzstr, timetuple)
+
 def main():
     # Address to check is required
     try:
         address = args[0]
-    except IndexError:
+        addr = Address.Factory(address)
+    except (IndexError, ValueError):
         usage(0)
 
     try:
@@ -109,20 +120,17 @@
         sender_address = None
 
     try:
-        addr = Address.Factory(address)
         addr.verify(sender_address)
         print "STATUS: VALID"
-        try:
-            print "EXPIRES: %s" % addr.timestamp(1, localtime)
-        except AttributeError:
-            pass
+        if addr.tag() in Defaults.TAGS_DATED:
+            print "EXPIRES: %s" % formattime(addr.timestamp())
+    except Address.ExpiredAddressError, msg:
+        print "STATUS:", msg
+        print "EXPIRED: %s" % formattime(addr.timestamp())
     except Address.AddressError, msg:
         print "STATUS:", msg
-        try:
-            print "EXPIRED: %s" % addr.timestamp(1, localtime)
-        except AttributeError:
-            pass
-        
+
+
 if __name__ == '__main__':
     main()
 

_______________________________________
tmda-cvs mailing list
http://tmda.net/lists/listinfo/tmda-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.