Revision a133af22 lib/utils.py
b/lib/utils.py | ||
---|---|---|
29 | 29 |
|
30 | 30 |
import sys |
31 | 31 |
import os |
32 |
import sha |
|
33 | 32 |
import time |
34 | 33 |
import subprocess |
35 | 34 |
import re |
... | ... | |
47 | 46 |
|
48 | 47 |
from cStringIO import StringIO |
49 | 48 |
|
49 |
try: |
|
50 |
from hashlib import sha1 |
|
51 |
except ImportError: |
|
52 |
import sha |
|
53 |
sha1 = sha.new |
|
54 |
|
|
50 | 55 |
from ganeti import errors |
51 | 56 |
from ganeti import constants |
52 | 57 |
|
... | ... | |
330 | 335 |
|
331 | 336 |
f = open(filename) |
332 | 337 |
|
333 |
fp = sha.sha()
|
|
338 |
fp = sha1()
|
|
334 | 339 |
while True: |
335 | 340 |
data = f.read(4096) |
336 | 341 |
if not data: |
... | ... | |
1179 | 1184 |
@return: a sha1 hexdigest of a block of 64 random bytes |
1180 | 1185 |
|
1181 | 1186 |
""" |
1182 |
return sha.new(os.urandom(64)).hexdigest()
|
|
1187 |
return sha1(os.urandom(64)).hexdigest()
|
|
1183 | 1188 |
|
1184 | 1189 |
|
1185 | 1190 |
def EnsureDirs(dirs): |
Also available in: Unified diff