зеркало из https://github.com/mozilla/kitsune.git
Revert "Revert [bug 839930] Update to Tweepy 2.0"
This reverts commit 0a4e2416f3
.
This commit is contained in:
Родитель
0a4e2416f3
Коммит
92ea9bf5d9
|
@ -4,9 +4,6 @@ import json
|
|||
import logging
|
||||
import re
|
||||
import rfc822
|
||||
import time
|
||||
import urllib
|
||||
import urllib2
|
||||
|
||||
from django.conf import settings
|
||||
from django.db.utils import IntegrityError
|
||||
|
@ -14,6 +11,7 @@ from django.db.utils import IntegrityError
|
|||
import cronjobs
|
||||
from multidb.pinning import pin_this_thread
|
||||
import tweepy
|
||||
from tweepy.parsers import RawParser
|
||||
from sumo.redis_utils import redis_client, RedisError
|
||||
from statsd import statsd
|
||||
|
||||
|
@ -33,6 +31,15 @@ log = logging.getLogger('k.twitter')
|
|||
def collect_tweets():
|
||||
"""Collect new tweets about Firefox."""
|
||||
with statsd.timer('customercare.tweets.time_elapsed'):
|
||||
auth = tweepy.OAuthHandler(settings.TWITTER_CONSUMER_KEY,
|
||||
settings.TWITTER_CONSUMER_SECRET,
|
||||
secure=True)
|
||||
|
||||
auth.set_access_token(settings.TWITTER_ACCESS_TOKEN,
|
||||
settings.TWITTER_ACCESS_TOKEN_SECRET)
|
||||
|
||||
api = tweepy.API(auth)
|
||||
|
||||
search_options = {
|
||||
'q': 'firefox OR #fxinput',
|
||||
'rpp': settings.CC_TWEETS_PERPAGE, # Items per page.
|
||||
|
@ -51,9 +58,8 @@ def collect_tweets():
|
|||
|
||||
# Retrieve Tweets
|
||||
try:
|
||||
raw_data = json.load(urllib.urlopen('%s?%s' % (
|
||||
SEARCH_URL, urllib.urlencode(search_options))))
|
||||
except Exception, e:
|
||||
raw_data = json.loads(str(api.search(**search_options)))
|
||||
except tweepy.TweepError, e:
|
||||
log.warning('Twitter request failed: %s' % e)
|
||||
return
|
||||
|
||||
|
|
|
@ -981,7 +981,8 @@ CC_BANNED_USERS = ['lucasbytegenius'] # Twitter handles banned from AoA
|
|||
TWITTER_COOKIE_SECURE = True
|
||||
TWITTER_CONSUMER_KEY = ''
|
||||
TWITTER_CONSUMER_SECRET = ''
|
||||
|
||||
TWITTER_ACCESS_TOKEN = ''
|
||||
TWITTER_ACCESS_TOKEN_SECRET = ''
|
||||
|
||||
TIDINGS_FROM_ADDRESS = 'notifications@support.mozilla.org'
|
||||
# Anonymous watches must be confirmed.
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit cf4ebd0d2698bbfa0ccf10a29399a396306de68a
|
||||
Subproject commit 957f2762c68b6d539b2733a01b4650a251f8cae4
|
Загрузка…
Ссылка в новой задаче