made changes to remove the warning about depracation of md5 module in python 2.6
This commit is contained in:
parent
b38b509bbd
commit
f77fe5163d
@ -363,7 +363,7 @@ class Api(object):
|
||||
if name == 'api_sig': continue
|
||||
sig += ("%s%s" % (name, params[name]))
|
||||
sig += self.secret
|
||||
hashed_sig = md5.new(sig).hexdigest()
|
||||
hashed_sig = md5hash(sig)
|
||||
return hashed_sig
|
||||
else:
|
||||
raise AuthenticationFailedError("api secret must be present to call this method")
|
||||
@ -387,7 +387,6 @@ class Api(object):
|
||||
return "<lastfm.Api: %s>" % self._api_key
|
||||
|
||||
from datetime import datetime
|
||||
import md5
|
||||
import sys
|
||||
import time
|
||||
import urllib
|
||||
@ -408,6 +407,15 @@ from lastfm.track import Track
|
||||
from lastfm.user import User
|
||||
from lastfm.venue import Venue
|
||||
|
||||
if sys.version < '2.6':
|
||||
import md5
|
||||
def md5hash(string):
|
||||
return md5.new(string).hexdigest()
|
||||
else:
|
||||
from hashlib import md5
|
||||
def md5hash(string):
|
||||
return md5(string).hexdigest()
|
||||
|
||||
if sys.version_info >= (2, 5):
|
||||
import xml.etree.cElementTree as ElementTree
|
||||
else:
|
||||
|
@ -4,7 +4,16 @@ __author__ = "Abhinav Sarkar <abhinav@abhinavsarkar.net>"
|
||||
__version__ = "0.2"
|
||||
__license__ = "GNU Lesser General Public License"
|
||||
|
||||
import md5
|
||||
import sys
|
||||
if sys.version < '2.6':
|
||||
import md5
|
||||
def md5hash(string):
|
||||
return md5.new(string).hexdigest()
|
||||
else:
|
||||
from hashlib import md5
|
||||
def md5hash(string):
|
||||
return md5(string).hexdigest()
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
@ -83,7 +92,7 @@ class FileCache(object):
|
||||
self._root_directory = root_directory
|
||||
|
||||
def _GetPath(self,key):
|
||||
hashed_key = md5.new(key).hexdigest()
|
||||
hashed_key = md5hash(key)
|
||||
return os.path.join(self._root_directory,
|
||||
self._GetPrefix(hashed_key),
|
||||
hashed_key)
|
||||
|
@ -1,6 +1,14 @@
|
||||
from urlparse import urlunparse
|
||||
import md5
|
||||
import os
|
||||
import sys
|
||||
if sys.version < '2.6':
|
||||
import md5
|
||||
def md5hash(string):
|
||||
return md5.new(string).hexdigest()
|
||||
else:
|
||||
from hashlib import md5
|
||||
def md5hash(string):
|
||||
return md5(string).hexdigest()
|
||||
"""
|
||||
A simple WSGI application for testing.
|
||||
"""
|
||||
@ -20,7 +28,7 @@ def test_app(environ, start_response):
|
||||
environ['QUERY_STRING'],
|
||||
''
|
||||
))
|
||||
key = md5.new(url).hexdigest()
|
||||
key = md5hash(url)
|
||||
status = '200 OK'
|
||||
response_headers = [('Content-type','text/xml')]
|
||||
start_response(status, response_headers)
|
||||
|
Loading…
Reference in New Issue
Block a user