コード例 #1
0
    def __init__(self, api_key, servers=TEST):
        """Sets up this module to make API calls. The first argument is the developer's
    API key and the second specifies which servers should be used.

    Arguments:
    api_key -- The developer's API key
    servers -- How the server URLs should be set. Must be PRODUCTION or TEST.
    """
        self.helper = APIHelper(api_key, servers)
コード例 #2
0
 def __init__(self):
     self.api = APIHelper()
     self.data = DataManager()
     self.web = WebHelper()
コード例 #3
0
        })

        config.logger.debug("Created config collection")
        config.logger.debug("\thash tags: {}".format(config.HASH_TAGS))
        config.logger.debug("\tnum tweets to search: {}".format(
            config.NUM_TWEETS_TO_SEARCH))
        config.logger.debug("\tpull tweets interval: {}".format(
            config.PULL_TWEETS_INTERVAL))

    for hash_tag in config.HASH_TAGS:
        config.logger.debug("\t\thash_tag: {}".format(hash_tag))


def run(tw_api, mongo_client):
    while True:
        config.logger.info("App is running")
        initialize(mongo_client)

        if not config.PAUSE_APP:
            pull_tweets(tw_api, mongo_client)
            process_pulled_tweets(tw_api, mongo_client)

        time.sleep(30)


if __name__ == "__main__":
    api_helper = APIHelper()
    tw_api, mongo_client = api_helper.create_api()
    config.logger.info("App started")
    run(tw_api, mongo_client)