@@ -1,4 +1,8 @@
-import os, md5
+import os
+try:
+ import hashlib
+except ImportError:
+ import md5
from autotest_lib.client.common_lib import utils
from autotest_lib.tko import utils as tko_utils
@@ -63,7 +67,11 @@ class kernel(object):
@staticmethod
def compute_hash(base, hashes):
key_string = ','.join([base] + hashes)
- return md5.new(key_string).hexdigest()
+ try:
+ hash = hashlib.md5(key_string).hexdigest()
+ except NameError:
+ hash = md5.new(key_string).hexdigest()
+ return hash
class test(object):
@@ -1,6 +1,10 @@
#!/usr/bin/python
-import unittest, datetime, time, md5
+import unittest, datetime, time
+try:
+ import hashlib
+except ImportError:
+ import md5
import common
from autotest_lib.tko.parsers import version_1
@@ -163,7 +167,10 @@ class test_status_line(unittest.TestCase):
"patch0": "first_patch 0 0",
"patch1": "another_patch 0 0"})
kern = line.get_kernel()
- kernel_hash = md5.new("2.6.24-rc40,0,0").hexdigest()
+ try:
+ kernel_hash = hashlib.md5("2.6.24-rc40,0,0").hexdigest()
+ except NameError:
+ kernel_hash = md5.new("2.6.24-rc40,0,0").hexdigest()
self.assertEquals(kern.base, "2.6.24-rc40")
self.assertEquals(kern.patches[0].spec, "first_patch")
self.assertEquals(kern.patches[1].spec, "another_patch")
@@ -178,7 +185,10 @@ class test_status_line(unittest.TestCase):
"patch0": "first_patch 0 0",
"patch2": "another_patch 0 0"})
kern = line.get_kernel()
- kernel_hash = md5.new("2.6.24-rc40,0").hexdigest()
+ try:
+ kernel_hash = hashlib.md5("2.6.24-rc40,0").hexdigest()
+ except:
+ kernel_hash = md5.new("2.6.24-rc40,0").hexdigest()
self.assertEquals(kern.base, "2.6.24-rc40")
self.assertEquals(kern.patches[0].spec, "first_patch")
self.assertEquals(len(kern.patches), 1)
@@ -12,7 +12,11 @@ Usage? Just run it.
utils/build_externals.py
"""
-import compileall, logging, os, sha, shutil, sys, tempfile, time, urllib2
+import compileall, logging, os, shutil, sys, tempfile, time, urllib2
+try:
+ import hashlib
+except ImportError:
+ import sha
import subprocess, re
import common
from autotest_lib.client.common_lib import logging_config, logging_manager
@@ -152,7 +156,10 @@ def _checksum_file(full_path):
"""@returns The hex checksum of a file given its pathname."""
inputfile = open(full_path, 'rb')
try:
- hex_sum = sha.sha(inputfile.read()).hexdigest()
+ try:
+ hex_sum = hashlib.sha1(inputfile.read()).hexdigest()
+ except NameError:
+ hex_sum = sha.sha(inputfile.read()).hexdigest()
finally:
inputfile.close()
return hex_sum