Example #1
0
    def __init__(self, config):
        consumer_key = config.get('main', 'consumer_key')
        consumer_secret = config.get('main', 'consumer_secret')
        access_key = config.get('main', 'access_key')
        access_secret = config.get('main', 'access_secret')

        Twython.__init__(self,
                         consumer_key,
                         consumer_secret,
                         access_key,
                         access_secret)

        self._request_oauth = OAuth1Session(consumer_key,
                                            consumer_secret,
                                            access_key,
                                            access_secret)

        self.ratelimit = CacheRatelimit(config)

        self.default_ratelimit = dict([(k, int(v))
                                       for k, v in config.items('ratelimit')])
        self.initialize_ratelimit()

        # monkey patch _request to check the ratelimit
        self._rt_request = self._request
        def request(url, *args, **kwargs):
            working_url = self.clean_url(url)
            if working_url in self.default_ratelimit:
                self.clean_records(working_url)
                self.record_call(working_url)
                self.has_reached_limit(working_url)

            return self._rt_request(url, *args, **kwargs)

        self._request = request
Example #2
0
    def __init__(self, source):

        self.name = 'twitter_streamer'
        self.count = 0

        # Logger
        Twython.__init__(self, TWITTER_ACCESS_KEYS["app_key"], TWITTER_ACCESS_KEYS["app_secret"],
                                 TWITTER_ACCESS_KEYS["app_access_token"],
                                 TWITTER_ACCESS_KEYS["app_access_token_secret"])
 def __init__(self, app_key, app_secret, oauth_token, oauth_token_secret):
     """
     :param app_key: (optional) Your applications key
     :param app_secret: (optional) Your applications secret key
     :param oauth_token: (optional) When using **OAuth 1**, combined with
         oauth_token_secret to make authenticated calls
     :param oauth_token_secret: (optional) When using **OAuth 1** combined
         with oauth_token to make authenticated calls
     """
     self.handler = None
     self.do_continue = True
     Twython.__init__(self, app_key, app_secret, oauth_token,
                      oauth_token_secret)
Example #4
0
    def __init__(self, source):

        self.name = 'twitter_streamer'
        self.count = 0

        # Logger
        #streamer_logging.init_logger(root_name=LOGGING_ROOT_NAME, level='DEBUG', log_base_path=LOGGING_BASE_PATH)
        #self.module_logger = logging.getLogger(LOGGING_ROOT_NAME + '.streamer')
        #self.module_logger.info("Starting twitter streamer...")

        Twython.__init__(self, TWITTER_ACCESS_KEYS["app_key"],
                         TWITTER_ACCESS_KEYS["app_secret"],
                         TWITTER_ACCESS_KEYS["app_access_token"],
                         TWITTER_ACCESS_KEYS["app_access_token_secret"])
Example #5
0
 def __init__(self, app_key, app_secret, oauth_token, oauth_token_secret):
     self.handler = None
     self.do_continue = True
     Twython.__init__(self, app_key, app_secret, oauth_token,
                      oauth_token_secret)
Example #6
0
 def __init__(self, app_key, app_secret, oauth_token, oauth_token_secret):
     self.handler = None
     self.do_continue = True
     Twython.__init__(self, app_key, app_secret, oauth_token, oauth_token_secret)
Example #7
0
 def __init__(self, app_key, app_secret, oauth_token, oauth_token_secret, filedir):
     self.filedir = filedir
     Twython.__init__(self, app_key, app_secret, oauth_token, oauth_token_secret)
     self.limits = {}
     self.update_limits()