mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-06-06 09:31:43 +00:00
use hashlib module if available, thus avoiding a DeprecationWarning for importing the old sha module; fixes #859
This commit is contained in:
parent
c1438805ce
commit
b69e1c600d
@ -28,7 +28,15 @@ the foolscap-based server implemented in src/allmydata/storage/*.py .
|
|||||||
#
|
#
|
||||||
# 6: implement other sorts of IStorageClient classes: S3, etc
|
# 6: implement other sorts of IStorageClient classes: S3, etc
|
||||||
|
|
||||||
import sha, time
|
try:
|
||||||
|
from hashlib import sha1
|
||||||
|
except ImportError:
|
||||||
|
# hashlib was added in Python 2.5
|
||||||
|
import sha
|
||||||
|
def sha1(x):
|
||||||
|
return sha.new(x)
|
||||||
|
|
||||||
|
import time
|
||||||
from zope.interface import implements, Interface
|
from zope.interface import implements, Interface
|
||||||
from foolscap.api import eventually
|
from foolscap.api import eventually
|
||||||
from allmydata.interfaces import IStorageBroker
|
from allmydata.interfaces import IStorageBroker
|
||||||
@ -119,7 +127,7 @@ class StorageFarmBroker:
|
|||||||
assert self.permute_peers == True
|
assert self.permute_peers == True
|
||||||
servers = self.get_all_servers()
|
servers = self.get_all_servers()
|
||||||
key = peer_selection_index
|
key = peer_selection_index
|
||||||
return sorted(servers, key=lambda x: sha.new(key+x[0]).digest())
|
return sorted(servers, key=lambda x: sha1(key+x[0]).digest())
|
||||||
|
|
||||||
def get_all_servers(self):
|
def get_all_servers(self):
|
||||||
# return a frozenset of (peerid, versioned-rref) tuples
|
# return a frozenset of (peerid, versioned-rref) tuples
|
||||||
|
Loading…
x
Reference in New Issue
Block a user