Skip to content

Commit

Permalink
md5 depreciated in Python 2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
nickperkins committed Nov 28, 2012
1 parent a518164 commit 18b2090
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.db
*.pyc
config.py
11 changes: 8 additions & 3 deletions cleverbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@

import urllib
import urllib2
import md5
import re

# md5 depreciated in Python 2.5
try:
from hashlib import md5
except ImportError:
from md5 import md5

class ServerFullError(Exception):
pass

Expand Down Expand Up @@ -60,7 +65,7 @@ def __init__(self):
def Send(self):
data = urllib.urlencode(self.params)
digest_txt = data[9:29]
self.params['icognocheck'] = md5.new(digest_txt).hexdigest()
self.params['icognocheck'] = md5(digest_txt).hexdigest()
data = urllib.urlencode(self.params)
print self.params
req = urllib2.Request("http://www.cleverbot.com/webservicemin", data, self.headers)
Expand Down Expand Up @@ -94,4 +99,4 @@ def previous(self):

def prevref(text):
pos = text.split('\r')
return pos[10]
return pos[10]

0 comments on commit 18b2090

Please sign in to comment.