[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[minion-cvs] Backport to Python 2.0



Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.seul.org:/tmp/cvs-serv15539/lib/mixminion

Modified Files:
	Common.py Crypto.py ServerInfo.py test.py 
Log Message:
Backport to Python 2.0

Index: Common.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Common.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- Common.py	25 Aug 2002 05:58:01 -0000	1.17
+++ Common.py	25 Aug 2002 06:10:33 -0000	1.18
@@ -182,13 +182,18 @@
 # I'm trying to make this interface look like a subset of the one in
 # the draft PEP-0282 (http://www.python.org/peps/pep-0282.html).
 
-def _logtime():
-    'Helper function.  Returns current local time formatted for log.'
-
-    # Note: Python strftime is implemented using that platform libc's
-    # strftime, so in theory, this might barf.  All of the format
-    # elements below are (I think) standard, so we should be ok.
-    return time.strftime("%b %d %H:%m:%S")
+if sys.version_info[:2] >= (2,1):
+    def _logtime():
+        'Helper function.  Returns current local time formatted for log.'
+        
+        # Note: Python strftime is implemented using that platform libc's
+        # strftime, so in theory, this might barf.  All of the format
+        # elements below are (I think) standard, so we should be ok.
+        return time.strftime("%b %d %H:%m:%S")
+else:
+    def _logtime():
+        'Helper function.  Returns current local time formatted for log.'
+        return time.strftime("%b %d %H:%m:%S", time.localtime(time.time()))
 
 class _FileLogHandler:
     """Helper class for logging.  Represents a file on disk, and allows the

Index: Crypto.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Crypto.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- Crypto.py	25 Aug 2002 05:58:02 -0000	1.17
+++ Crypto.py	25 Aug 2002 06:10:34 -0000	1.18
@@ -427,7 +427,7 @@
         # FFFF This implementation is about 2-4x as good as the last one, but
 	# FFFF still could be better.  It's faster than getFloat()*max.
 
-        assert 0 < max < 0x3ffffffff
+        assert 0 < max < 0x3fffffff
 	_ord = ord
 	while 1:
 	    # Get a random positive int between 0 and 0x7fffffff.

Index: ServerInfo.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ServerInfo.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- ServerInfo.py	25 Aug 2002 05:58:02 -0000	1.11
+++ ServerInfo.py	25 Aug 2002 06:10:35 -0000	1.12
@@ -12,7 +12,7 @@
 
 import time
 import os
-import binascii
+import base64
 import socket
 
 from mixminion.Common import createPrivateDir
@@ -179,7 +179,7 @@
 
 def _base64(s):
     "Helper function: returns a one-line base64 encoding of a given string."
-    return binascii.b2a_base64(s).replace("\n","")
+    return base64.encodestring(s).replace("\n", "")
 
 def _time(t):
     """Helper function: turns a time (in seconds) into the format used by
@@ -385,7 +385,7 @@
 
     signature = mixminion.Crypto.pk_sign(digest,rsa)
     digest = _base64(digest)
-    signature = binascii.b2a_base64(signature).replace("\n","")
+    signature = base64.encodestring(signature).replace("\n","")
     infoLines[digestLine] = 'Digest: '+digest
     infoLines[signatureLine] = 'Signature: '+signature
 

Index: test.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/test.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- test.py	25 Aug 2002 05:58:02 -0000	1.23
+++ test.py	25 Aug 2002 06:10:35 -0000	1.24
@@ -19,7 +19,7 @@
 import time
 import types
 import re
-import binascii
+import base64
 import stat
 import cPickle
 
@@ -2128,7 +2128,7 @@
         
         # Now with a bad signature
         sig2 = mixminion.Crypto.pk_sign(sha1("Hello"), identity)
-        sig2 = binascii.b2a_base64(sig2).replace("\n", "")
+        sig2 = base64.encodestring(sig2).replace("\n", "")
         sigpat = re.compile('^Signature:.*$', re.M)
         badSig = sigpat.sub("Signature: %s" % sig2, inf)
         self.failUnlessRaises(ConfigError,