backend/server/rhnActivationKey.py | 4 ++--
backend/spacewalk/common/rhn_rpm.py | 7 +++----
client/tools/osad/src/jabber_lib.py | 14 +++++++-------
client/tools/rhncfg/config_common/utils.py | 14 ++++++++++++--
4 files changed, 24 insertions(+), 15 deletions(-)
New commits:
commit 6c9624ab7ec3a9962030a755c86e0d1f3617d40b
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri Jan 29 20:53:42 2010 +0100
fixed DeprecationWarning: the sha module is deprecated; use the hashlib module instead
diff --git a/client/tools/rhncfg/config_common/utils.py b/client/tools/rhncfg/config_common/utils.py
index 9e7b763..6f89326 100644
--- a/client/tools/rhncfg/config_common/utils.py
+++ b/client/tools/rhncfg/config_common/utils.py
@@ -14,7 +14,17 @@
#
import os
-import sha
+try:
+ import hashlib
+except ImportError:
+ import sha
+ class hashlib:
+ @staticmethod
+ def new(checksum):
+ if checksum == 'sha1':
+ return sha.new()
+ else:
+ raise ValueError, "Incompatible checksum type"
import re
import string
import shutil
@@ -146,7 +156,7 @@ def rm_trailing_slash(slashstring):
def sha1_file(file):
- engine = sha.new()
+ engine = hashlib.new('sha1')
fh = open(file, "r")
while 1:
commit feae47010f2db21c8c32558c71326bf47b00e48c
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri Jan 29 20:48:04 2010 +0100
fixed DeprecationWarning: the sha module is deprecated; use the hashlib module instead
diff --git a/client/tools/osad/src/jabber_lib.py b/client/tools/osad/src/jabber_lib.py
index bbe2b4b..403b5b7 100644
--- a/client/tools/osad/src/jabber_lib.py
+++ b/client/tools/osad/src/jabber_lib.py
@@ -14,7 +14,7 @@
#
import os
-import sha
+import hashlib
import sys
import time
import types
@@ -332,9 +332,9 @@ def check_cert(cert_path):
raise InvalidCertError("Expired certificate", cert_path)
def sign(secret_key, *values):
- h = sha.new(secret_key).hexdigest()
+ h = hashlib.new('sha1', secret_key).hexdigest()
for v in values:
- h = sha.new(h + str(v)).hexdigest()
+ h = hashlib.new('sha1', h + str(v)).hexdigest()
return h
class JabberCallback:
@@ -870,13 +870,13 @@ class JabberClient(jabber.Client):
token = auth_ret_query.getTag('token').getData()
seq = auth_ret_query.getTag('sequence').getData()
- h = sha.new(sha.new(password).hexdigest() + token).hexdigest()
+ h = hashlib.new('sha1', hashlib.new('sha1', password).hexdigest() + token).hexdigest()
for i in range(int(seq)):
- h = sha.new(h).hexdigest()
+ h = hashlib.new('sha1', h).hexdigest()
q.insertTag('hash').insertData(h)
elif auth_ret_query.getTag('digest'):
digest = q.insertTag('digest')
- digest.insertData(sha.new(
+ digest.insertData(hashlib.new('sha1',
self.getIncomingID() + password).hexdigest() )
else:
q.insertTag('password').insertData(password)
@@ -1332,7 +1332,7 @@ def generate_random_string(length=20):
return ''
random_bytes = 16
length = int(length)
- s = sha.new()
+ s = hashlib.new('sha1')
s.update("%.8f" % time.time())
s.update(str(os.getpid()))
devrandom = open('/dev/urandom')
commit 7e2fb653142df7675b49a80eedb4d79976bbc0b1
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri Jan 29 20:39:40 2010 +0100
fixed DeprecationWarning: the sha module is deprecated; use the hashlib module instead
diff --git a/backend/server/rhnActivationKey.py b/backend/server/rhnActivationKey.py
index fe7930b..4a63613 100644
--- a/backend/server/rhnActivationKey.py
+++ b/backend/server/rhnActivationKey.py
@@ -17,7 +17,7 @@
# $Id$
import os
-import sha
+import hashlib
import time
import types
@@ -184,7 +184,7 @@ class ActivationKey:
def generate_token(self):
- s = sha.new()
+ s = hashlib.new('sha1')
s.update(str(os.getpid()))
for field in ['org_id', 'user_id', 'server_id']:
if self._row_reg_token.has_key(field):
commit b1b0e8025d31c0112dbf5b75d49155826052e8e0
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri Jan 29 20:07:39 2010 +0100
having __getattr__ defined by getattr causes recursion
but removing __getattr__ made hdrFromFdno() unknown so defined it explicitely
adressed
Exception RuntimeError: 'maximum recursion depth exceeded while calling
a Python object' in <type 'exceptions.AttributeError'> ignored
in if not hasattr(self, 'ts'):
diff --git a/backend/spacewalk/common/rhn_rpm.py b/backend/spacewalk/common/rhn_rpm.py
index 2c6cbe4..c2555f5 100644
--- a/backend/spacewalk/common/rhn_rpm.py
+++ b/backend/spacewalk/common/rhn_rpm.py
@@ -65,9 +65,6 @@ class RPMTransaction:
self.ts = rpm.TransactionSet()
self.tsflags = []
- def __getattr__(self, attr):
- return getattr(self.ts, attr)
-
def getMethod(self, method):
# in theory, we can override this with
# profile/etc info
@@ -109,6 +106,8 @@ class RPMTransaction:
def run(self, callback, user_data):
return self.ts.run(callback, user_data)
+ def hdrFromFdno(self, fd):
+ return self.ts.hdrFromFdno(fd)
@@ -274,7 +273,7 @@ def get_package_header(filename=None, file=None, fd=None):
# RHEL-4 and older, do the old way
ts = RPMReadOnlyTransaction()
ts.pushVSFlags(~(rpm.RPMVSF_NOMD5 | rpm.RPMVSF_NEEDPAYLOAD))
- hdr = RPMReadOnlyTransaction().hdrFromFdno(file_desc)
+ hdr = ts.hdrFromFdno(file_desc)
ts.popVSFlags()
if hdr is None:
raise InvalidPackageError