Correct twitter library in requirements.

This also requires updating the required version of oauthlib; previously an
appropriate version was being installed only because it was a dependency of
the wrong twitter library.

This only affects development environments and/or hand-built
installations relying on the contents of requirements.txt.

To fix existing environments, the incorrect api needs to be explicitly
removed with `pip uninstall twitter`.

Fixes #86.
This commit is contained in:
Darren Worrall 2015-09-30 20:01:37 +01:00 committed by Tim Abbott
parent 21b7048e54
commit 8b002040e0
2 changed files with 7 additions and 4 deletions

View File

@ -33,7 +33,7 @@ jwt==0.3.2
mandrill==1.0.57 mandrill==1.0.57
mock==1.0.1 mock==1.0.1
oauth2client==1.4.11 oauth2client==1.4.11
oauthlib==0.1.3 oauthlib==1.0.3
pika==0.9.14 pika==0.9.14
postmonkey==1.0b0 postmonkey==1.0b0
psycopg2==2.6 psycopg2==2.6
@ -56,7 +56,7 @@ smmap==0.9.0
sockjs-tornado==1.0.1 sockjs-tornado==1.0.1
sourcemap==0.1.8 sourcemap==0.1.8
tornado==2.4.1 tornado==2.4.1
twitter==1.17.0 python-twitter==1.1
ujson==1.33 ujson==1.33
uritemplate==0.6 uritemplate==0.6
wsgiref==0.1.2 wsgiref==0.1.2

View File

@ -106,9 +106,8 @@ def fetch_tweet_data(tweet_id):
if not all(creds.values()): if not all(creds.values()):
return None return None
api = twitter.Api(**creds)
try: try:
api = twitter.Api(**creds)
# Sometimes Twitter hangs on responses. Timing out here # Sometimes Twitter hangs on responses. Timing out here
# will cause the Tweet to go through as-is with no inline # will cause the Tweet to go through as-is with no inline
# preview, rather than having the message be rejected # preview, rather than having the message be rejected
@ -117,6 +116,10 @@ def fetch_tweet_data(tweet_id):
tweet = timeout(3, api.GetStatus, tweet_id) tweet = timeout(3, api.GetStatus, tweet_id)
res = tweet.AsDict() res = tweet.AsDict()
res['media'] = tweet.media # AsDict does not include media res['media'] = tweet.media # AsDict does not include media
except AttributeError:
logging.error('Unable to load twitter api, you may have the wrong '
'library installed, see https://github.com/zulip/zulip/issues/86')
return None
except TimeoutExpired as e: except TimeoutExpired as e:
# We'd like to try again later and not cache the bad result, # We'd like to try again later and not cache the bad result,
# so we need to re-raise the exception (just as though # so we need to re-raise the exception (just as though