From 8a5fffa7cf70c520b314bb9320623b2d2b7d2cfd Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 24 Sep 2013 14:38:12 -0400 Subject: [PATCH] Move twitter API credentials to local_settings.py. (imported from commit 6b95db113b91816fbc5e91db4b1be90d3df8e028) --- zerver/lib/bugdown/__init__.py | 25 +++++-------------------- zproject/local_settings.py | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/zerver/lib/bugdown/__init__.py b/zerver/lib/bugdown/__init__.py index 65e7983124..c25949556e 100644 --- a/zerver/lib/bugdown/__init__.py +++ b/zerver/lib/bugdown/__init__.py @@ -82,26 +82,11 @@ def fetch_tweet_data(tweet_id): import testing_mocks res = testing_mocks.twitter(tweet_id) else: - if settings.STAGING_DEPLOYED or settings.TESTING_DEPLOYED: - # Application: "Humbug HQ" - api = twitter.Api(consumer_key = 'xxxxxxxxxxxxxxxxxxxxxx', - consumer_secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - access_token_key = 'xxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - access_token_secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') - elif settings.DEPLOYED: - # This is the real set of API credentials used by our real server, - # and we probably shouldn't test with it just so we don't waste its requests - # Application: "Humbug HQ - Production" - api = twitter.Api(consumer_key = 'xxxxxxxxxxxxxxxxxxxxx', - consumer_secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - access_token_key = 'xxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - access_token_secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') - else: - # Application: "Humbug HQ Test" - api = twitter.Api(consumer_key = 'xxxxxxxxxxxxxxxxxxxxxx', - consumer_secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - access_token_key = 'xxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - access_token_secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') + api = twitter.Api(consumer_key = settings.TWITTER_CONSUMER_KEY, + consumer_secret = settings.TWITTER_CONSUMER_SECRET, + access_token_key = settings.TWITTER_ACCESS_TOKEN_KEY, + access_token_secret = settings.TWITTER_ACCESS_TOKEN_SECRET) + try: # Sometimes Twitter hangs on responses. Timing out here # will cause the Tweet to go through as-is with no inline diff --git a/zproject/local_settings.py b/zproject/local_settings.py index b2c8308ecc..ea89966bea 100644 --- a/zproject/local_settings.py +++ b/zproject/local_settings.py @@ -59,3 +59,25 @@ else: S3_AVATAR_BUCKET="humbug-user-avatars-test" MIXPANEL_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + +# Twitter API credentials +if STAGING_DEPLOYED or TESTING_DEPLOYED: + # Application: "Humbug HQ" + TWITTER_CONSUMER_KEY = "xxxxxxxxxxxxxxxxxxxxxx" + TWITTER_CONSUMER_SECRET = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + TWITTER_ACCESS_TOKEN_KEY = "xxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + TWITTER_ACCESS_TOKEN_SECRET = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +elif DEPLOYED: + # This is the real set of API credentials used by our real server, + # and we probably shouldn't test with it just so we don't waste its requests + # Application: "Humbug HQ - Production" + TWITTER_CONSUMER_KEY = "xxxxxxxxxxxxxxxxxxxxx" + TWITTER_CONSUMER_SECRET = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + TWITTER_ACCESS_TOKEN_KEY = "xxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + TWITTER_ACCESS_TOKEN_SECRET = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +else: + # Application: "Humbug HQ Test" + TWITTER_CONSUMER_KEY = "xxxxxxxxxxxxxxxxxxxxxx" + TWITTER_CONSUMER_SECRET = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + TWITTER_ACCESS_TOKEN_KEY = "xxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + TWITTER_ACCESS_TOKEN_SECRET = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"