On Tue, May 5, 2009 at 14:32, Iustin Pop <[email protected]> wrote:
> The above could simply be rewritten as:
>     sha1 = sha.new

Here it goes:

diff --git a/lib/utils.py b/lib/utils.py
index fe0dcb1..3048779 100644
--- a/lib/utils.py
+++ b/lib/utils.py
@@ -29,7 +29,6 @@ the command line scripts.

 import sys
 import os
-import sha
 import time
 import subprocess
 import re
@@ -47,6 +46,12 @@ import signal

 from cStringIO import StringIO

+try:
+  from hashlib import sha1
+except ImportError:
+  import sha
+  sha1 = sha.new
+
 from ganeti import errors
 from ganeti import constants

@@ -330,7 +335,7 @@ def _FingerprintFile(filename):

   f = open(filename)

-  fp = sha.sha()
+  fp = sha1()
   while True:
     data = f.read(4096)
     if not data:
@@ -1179,7 +1184,7 @@ def GenerateSecret():
   @return: a sha1 hexdigest of a block of 64 random bytes

   """
-  return sha.new(os.urandom(64)).hexdigest()
+  return sha1(os.urandom(64)).hexdigest()


 def EnsureDirs(dirs):

Reply via email to