Пример #1
0
 def __init__(self):
     self.api_base_url = 'https://api.betfair.com/exchange/betting/json-rpc/v1'
     self.APP_KEY_DELAYED = CommonUtils.get_environ_variable('BET_FAIR_APP_KEY_DELAYED')
     self.APP_KEY = CommonUtils.get_environ_variable('BET_FAIR_APP_KEY_NONDELAYED')
     self.BET_FAIR_SESSION_TOKEN = CommonUtils.get_environ_variable('BET_FAIR_SESSION_TOKEN')
     self.BET_FAIR_USERNAME = CommonUtils.get_environ_variable('BET_FAIR_USERNAME')
     self.BET_FAIR_PASSWORD = CommonUtils.get_environ_variable('BET_FAIR_PASSWORD')
     self.api_call_headers = {}
Пример #2
0
 def test_get_aws_mongo_db(self):
     eternal_process = EternalProcess()
     uri = 'mongodb://' + CommonUtils.get_environ_variable('AWS_MONGO_USER') + ':' \
           + CommonUtils.get_environ_variable('AWS_MONGO_PASS') + '@' \
           + CommonUtils.get_environ_variable('AWS_ADDRESS')
     client = MongoClient(uri)
     expected = client.eventsDB
     self.assertEqual(expected, eternal_process.get_aws_mongo_db())
Пример #3
0
 def return_games_for_the_day():
     uri = 'mongodb://' + CommonUtils.get_environ_variable('AWS_MONGO_USER') + ':' \
           + CommonUtils.get_environ_variable('AWS_MONGO_PASS') + '@' \
           + CommonUtils.get_environ_variable('AWS_ADDRESS')
     client = MongoClient(uri)
     db = client.eventsDB
     data = []
     for post in db.mm_games.find():
         if post['normalized_date'] == datetime.datetime.now().strftime('%Y-%m-%d'):
             data.append(post)
     return data
Пример #4
0
 def __init__(self):
     """
     Initializes API keys and sets up Auth with Twitter API
     """
     self.APP_KEY = CommonUtils.get_environ_variable('SPORTS_CANARY_APP_KEY')
     self.APP_SECRET = CommonUtils.get_environ_variable('SPORTS_CANARY_APP_KEY_SECRET')
     self.OAUTH_TOKEN = CommonUtils.get_environ_variable('SPORTS_CANARY_OAUTH_TOKEN')
     self.OAUTH_TOKEN_SECRET = CommonUtils.get_environ_variable('SPORTS_CANARY_OAUTH_TOKEN_SECRET')
     self.auth = tweepy.OAuthHandler(self.APP_KEY, self.APP_SECRET)
     self.auth.set_access_token(self.OAUTH_TOKEN, self.OAUTH_TOKEN_SECRET)
     self.api = tweepy.API(self.auth)
Пример #5
0
 def __init__(self):
     """
     Initializes API keys and sets up Auth with Twitter API
     """
     self.APP_KEY = CommonUtils.get_environ_variable('SPORTS_CANARY_APP_KEY')
     self.APP_SECRET = CommonUtils.get_environ_variable('SPORTS_CANARY_APP_KEY_SECRET')
     self.OAUTH_TOKEN = CommonUtils.get_environ_variable('SPORTS_CANARY_OAUTH_TOKEN')
     self.OAUTH_TOKEN_SECRET = CommonUtils.get_environ_variable('SPORTS_CANARY_OAUTH_TOKEN_SECRET')
     self.auth = tweepy.OAuthHandler(self.APP_KEY, self.APP_SECRET)
     self.auth.set_access_token(self.OAUTH_TOKEN, self.OAUTH_TOKEN_SECRET)
     self.api = tweepy.API(self.auth)
     self.logger = logging.getLogger(__name__)
     self.keyword_generator = KeywordGenerator()
     self.score_updater = ScoreUpdater()
Пример #6
0
 def update_is_streamed_json(game):  # pragma: no cover
     """
     Replaces json file to reflect that game is being streamed
     :param game: game object similar to stattleship api
     """
     game_id = game["_id"]
     uri = 'mongodb://' + CommonUtils.get_environ_variable('AWS_MONGO_USER') + ':' \
           + CommonUtils.get_environ_variable('AWS_MONGO_PASS') + '@' \
           + CommonUtils.get_environ_variable('AWS_ADDRESS')
     client = MongoClient(uri)
     db = client.eventsDB
     if game["being_streamed"]:
         db.mm_games.update({'_id': game_id}, {"$set": {"being_streamed": False}}, upsert=False)
     else:
         db.mm_games.update({'_id': game_id}, {"$set": {"being_streamed": True}}, upsert=False)
Пример #7
0
 def write_days_games_data(self):  # pragma: no cover
     """
     Writes API response containing info for days games
     """
     uri = 'mongodb://' + CommonUtils.get_environ_variable('AWS_MONGO_USER') + ':' \
           + CommonUtils.get_environ_variable('AWS_MONGO_PASS') + '@' \
           + CommonUtils.get_environ_variable('AWS_ADDRESS')
     client = MongoClient(uri)
     db = client.eventsDB
     data_to_write = self.get_march_madness_games_for_the_day()
     try:
         db.mm_games.insert(data_to_write)
     except:
         print 'Error'
     return True
 def __init__(self):
     self.api_key_array = []
     self.number_of_keys = int(CommonUtils.get_environ_variable('NUMBER_OF_TWITTER_KEYS_AVAILABLE'))
     wd = os.getcwd()
     pos = wd.find("BigDataMonsters")
     if pos > 0:  # pragma: no cover
         path = wd[0:pos+15]
     else:
         path = wd
     self.key_check_write_path = path + '/Twitter_Utils/data/Active_API_Log.json'
     self.logger = logging.getLogger(__name__)
Пример #9
0
 def __init__(self):
     super(DataGatherer, self).__init__()
     self.APP_KEY = CommonUtils.get_environ_variable('TWITTER_APP_KEY')
     self.APP_SECRET = CommonUtils.get_environ_variable('TWITTER_APP_SECRET_0')
     self.OAUTH_TOKEN = CommonUtils.get_environ_variable('TWITTER_OAUTH_TOKEN_0')
     self.OAUTH_TOKEN_SECRET = CommonUtils.get_environ_variable('TWITTER_OAUTH_TOKEN_SECRET_0')
     self.processor = TweetProcessor()
     self.key_handler = TwitterAPIKeyHandler()
     self.key_array = self.key_handler.get_api_keys_from_environment()
     self.game_id_to_store = ''
     self.game_name_to_store = ''
     self.auth = OAuthHandler(self.APP_KEY, self.APP_SECRET)
     self.auth.set_access_token(self.OAUTH_TOKEN, self.OAUTH_TOKEN_SECRET)
     self.api = API(self.auth)
     self.logger = logging.getLogger(__name__)
     self.home_team_file_path = ''
     self.away_team_file_path = ''
     self.common_file_path = ''
     self.dir_path = ''
     self.home_team_track_words = ''
     self.away_team_track_words = ''
    def get_api_keys_from_environment(self):
        """
        Gets all API keys we have saved to our environment.
        :return: returns an array of individual dictionary entries with key info.
        """
        for key in range(0, self.number_of_keys):
            app_key = 'TWITTER_APP_KEY_' + str(key)
            app_secret = 'TWITTER_APP_SECRET_' + str(key)
            oauth_token = 'TWITTER_OAUTH_TOKEN_' + str(key)
            oauth_token_secret = 'TWITTER_OAUTH_TOKEN_SECRET_' + str(key)

            app_key = CommonUtils.get_environ_variable(app_key)
            app_secret = CommonUtils.get_environ_variable(app_secret)
            oauth_token = CommonUtils.get_environ_variable(oauth_token)
            oauth_token_secret = CommonUtils.get_environ_variable(oauth_token_secret)

            individual_key = dict(app_key=app_key,
                                  app_secret=app_secret,
                                  oauth_token=oauth_token,
                                  oauth_token_secret=oauth_token_secret)
            self.api_key_array.append(individual_key)

        return self.api_key_array
Пример #11
0
 def __init__(self):
     self.CLIENT_ID = CommonUtils.get_environ_variable('STAT_CLIENT_ID')
     self.STAT_CLIENT_SECRET = CommonUtils.get_environ_variable('STAT_CLIENT_SECRET')
     self.STAT_ACCESS_TOKEN = CommonUtils.get_environ_variable('STAT_ACCESS_TOKEN')
     self.logger = logging.getLogger(__name__)