_host = host or api.host
# Continue attempting request until successful
- # or maxium number of retries is reached.
+ # or maximum number of retries is reached.
retries_performed = 0
while retries_performed < retry_count + 1:
# Open connection
# Parse json respone body
try:
jobject = json.loads(resp.read())
- except Exception:
- raise TweepError("Failed to parse json response text")
+ except Exception, e:
+ raise TweepError("Failed to parse json: %s" % e)
# Parse cursor infomation
if isinstance(jobject, dict):
out = parser(jobject, api), next_cursor, prev_cursor
else:
out = parser(jobject, api)
- except Exception:
- raise TweepError("Failed to parse json object")
+ except Exception, e:
+ raise TweepError("Failed to parse response: %s" % e)
conn.close()
import htmlentitydefs
import re
from datetime import datetime
+import time
from tweepy.models import models
def _parse_datetime(str):
- return datetime.strptime(str, '%a %b %d %H:%M:%S +0000 %Y')
+ # We must parse datetime this way to work in python 2.4
+ return datetime(*(time.strptime(str, '%a %b %d %H:%M:%S +0000 %Y')[0:6]))
def _parse_search_datetime(str):
- return datetime.strptime(str, '%a, %d %b %Y %H:%M:%S +0000')
+ # python 2.4
+ return datetime(*(time.strptime(str, '%a, %d %b %Y %H:%M:%S +0000')[0:6]))
def unescape_html(text):