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