Worked in some try/catch support for loading and hitting the API - needs to happen for other functions as well, once I have more time.

This commit is contained in:
Ryan McGrath 2009-05-14 01:38:37 -04:00
parent 1f544c6aaf
commit c47d6008a0

View file

@ -31,11 +31,17 @@ class setup:
return queryURL
def getPublicTimeline(self):
publicTimeline = simplejson.load(urllib2.urlopen("http://twitter.com/statuses/public_timeline.json"))
formattedTimeline = []
for tweet in publicTimeline:
formattedTimeline.append(tweet['text'])
return formattedTimeline
try:
publicTimeline = simplejson.load(urllib2.urlopen("http://twitter.com/statuses/public_timeline.json"))
formattedTimeline = []
for tweet in publicTimeline:
formattedTimeline.append(tweet['text'])
return formattedTimeline
except IOError, e:
if hasattr(e, 'code'):
return "Loading API failed with HTTP Status Code " + e.code
else:
return "God help us all, Scotty, she's dead and we're not sure why."
def getUserTimeline(self, **kwargs):
# 99% API compliant, I think - need to figure out Gzip compression and auto-getting based on authentication