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