def init(self): self.cache = Cache( self.parameters.redis_cache_host, self.parameters.redis_cache_port, self.parameters.redis_cache_db, self.parameters.redis_cache_ttl, )
def init(self): self.apikey = getattr(self.parameters, "api_key", None) if self.apikey is None: raise ValueError('No api_key provided.') self.secret = getattr(self.parameters, "secret", None) if self.secret is None: raise ValueError('No secret provided.') self.country = getattr(self.parameters, "country", None) if self.country is None: raise ValueError('No country provided.') self.types = getattr(self.parameters, 'types', None) if isinstance(self.types, str): self.types = self.types.split(',') self.preamble = '{{ "apikey": "{}" '.format(self.apikey) self.set_request_parameters() self.session = create_request_session(self) self.cache = Cache( self.parameters.redis_cache_host, self.parameters.redis_cache_port, self.parameters.redis_cache_db, getattr(self.parameters, 'redis_cache_ttl', 864000), # 10 days getattr(self.parameters, "redis_cache_password", None))
def tearDownClass(cls): cache = Cache(test.BOT_CONFIG['redis_cache_host'], test.BOT_CONFIG['redis_cache_port'], test.BOT_CONFIG['redis_cache_db'], test.BOT_CONFIG['redis_cache_ttl'], ) cache.flush()
def init(self): self.cache = Cache( self.parameters.redis_cache_host, self.parameters.redis_cache_port, self.parameters.redis_cache_db, self.parameters.redis_cache_ttl, getattr(self.parameters, "redis_cache_password", None)) self.filter_keys = set(k.strip() for k in self.parameters.filter_keys.split(','))
def init(self): self.set_request_parameters() self.http_header['Ocp-Apim-Subscription-Key'] = self.parameters.api_key if self.parameters.file_match: self.file_match = re.compile(self.parameters.file_match) else: self.file_match = None if self.parameters.not_older_than: try: self.time_match = timedelta( minutes=parse_relative(self.parameters.not_older_than)) except ValueError: self.time_match = parser.parse(self.parameters.not_older_than) self.logger.info("Filtering files absolute %r.", self.time_match) else: self.logger.info("Filtering files relative %r.", self.time_match) else: self.time_match = None self.cache = Cache( self.parameters.redis_cache_host, self.parameters.redis_cache_port, self.parameters.redis_cache_db, self.parameters.redis_cache_ttl, getattr(self.parameters, "redis_cache_password", None))
def init(self): if requests is None: raise ValueError('Could not import requests. Please install it.') if hasattr(self.parameters, 'query_ripe_stat'): self.logger.warning( "The parameter 'query_ripe_stat' is deprecated and will be " "removed in 2.0. Use 'query_ripe_stat_asn' and " "'query_ripe_stat_ip' instead'.") self.query_db_asn = getattr(self.parameters, 'query_ripe_db_asn', True) self.query_db_ip = getattr(self.parameters, 'query_ripe_db_ip', True) self.query_stat_asn = getattr( self.parameters, 'query_ripe_stat_asn', getattr(self.parameters, 'query_ripe_stat', True)) self.query_stat_ip = getattr( self.parameters, 'query_ripe_stat_ip', getattr(self.parameters, 'query_ripe_stat', True)) self.mode = getattr(self.parameters, 'mode', 'append') self.set_request_parameters() cache_host = getattr(self.parameters, 'redis_cache_host') cache_port = getattr(self.parameters, 'redis_cache_port') cache_db = getattr(self.parameters, 'redis_cache_db') cache_ttl = getattr(self.parameters, 'redis_cache_ttl') if cache_host and cache_port and cache_db and cache_ttl: self.cache = Cache( cache_host, cache_port, cache_db, cache_ttl, getattr(self.parameters, "redis_cache_password", None))
def __initialize_cache(self): cache_host = getattr(self.parameters, 'redis_cache_host') cache_port = getattr(self.parameters, 'redis_cache_port') cache_db = getattr(self.parameters, 'redis_cache_db') cache_ttl = getattr(self.parameters, 'redis_cache_ttl') if cache_host and cache_port and cache_db and cache_ttl: self.__cache = Cache(cache_host, cache_port, cache_db, cache_ttl, getattr(self.parameters, "redis_cache_password", None))
def init(self): self.cache = Cache(self.parameters.redis_cache_host, self.parameters.redis_cache_port, self.parameters.redis_cache_db, self.parameters.redis_cache_ttl, getattr(self.parameters, "redis_cache_password", None) )
def init(self): self.cache = Cache( self.parameters.redis_cache_host, self.parameters.redis_cache_port, self.parameters.redis_cache_db, self.parameters.redis_cache_ttl ) self.logger.warning("Bot init succesful.")
def init(self): print("joooo") self.cache = Cache( self.parameters.redis_cache_host, self.parameters.redis_cache_port, self.parameters.redis_cache_db, self.parameters.redis_cache_ttl, )
def init(self): self.query_db_asn = getattr(self.parameters, 'query_ripe_db_asn', True) self.query_db_ip = getattr(self.parameters, 'query_ripe_db_ip', True) self.query_stat_asn = getattr(self.parameters, 'query_ripe_stat', True) self.query_stat_ip = getattr(self.parameters, 'query_ripe_stat', True) self.cache = Cache( self.parameters.redis_cache_host, self.parameters.redis_cache_port, self.parameters.redis_cache_db, self.parameters.redis_cache_ttl, )
def init(self): self.cache = Cache( self.parameters.redis_cache_host, self.parameters.redis_cache_port, self.parameters.redis_cache_db, self.parameters.redis_cache_ttl, getattr(self.parameters, "redis_cache_password", None)) if not hasattr(self.parameters, 'overwrite'): self.logger.warning( "Parameter 'overwrite' is not given, assuming 'True'. " "Please set it explicitly, default will change to " "'False' in version 3.0.0'.") self.overwrite = getattr(self.parameters, 'overwrite', True)
def init(self): if requests is None: raise ValueError('Could not import requests. Please install it.') self.set_request_parameters() self.http_header['Ocp-Apim-Subscription-Key'] = self.parameters.api_key if self.parameters.file_match: self.file_match = re.compile(self.parameters.file_match) else: self.file_match = None if self.parameters.not_older_than: try: self.time_match = timedelta( minutes=parse_relative(self.parameters.not_older_than)) except ValueError: if sys.version_info >= (3, 6): self.time_match = parser.parse( self.parameters.not_older_than).astimezone(pytz.utc) else: # "astimezone() cannot be applied to a naive datetime" otherwise if '+' not in self.parameters.not_older_than: self.parameters.not_older_than += '+00:00' self.time_match = parser.parse( self.parameters.not_older_than) self.logger.info("Filtering files absolute %r.", self.time_match) self.check_ttl_time() else: self.logger.info("Filtering files relative %r.", self.time_match) if timedelta(seconds=self.parameters.redis_cache_ttl ) < self.time_match: raise ValueError( "The cache's TTL must be higher than 'not_older_than', " "otherwise the bot is processing the same data over and over again." ) else: self.time_match = None self.session = create_request_session_from_bot(self) self.cache = Cache( self.parameters.redis_cache_host, self.parameters.redis_cache_port, self.parameters.redis_cache_db, self.parameters.redis_cache_ttl, getattr(self.parameters, "redis_cache_password", None))
def init(self): if ContainerClient is None or create_configuration is None: raise MissingDependencyError("azure.storage") self.config = create_configuration(storage_sdk='blob') if hasattr(self.parameters, 'https_proxy'): # Create a storage configuration object and update the proxy policy self.config.proxy_policy.proxies = { 'http': self.parameters.http_proxy, 'https': self.parameters.https_proxy, } self.cache = Cache( self.parameters.redis_cache_host, self.parameters.redis_cache_port, self.parameters.redis_cache_db, getattr(self.parameters, 'redis_cache_ttl', 864000), # 10 days getattr(self.parameters, "redis_cache_password", None))
def init(self): self.cache = Cache( self.parameters.redis_cache_host, self.parameters.redis_cache_port, self.parameters.redis_cache_db, self.parameters.timeout, getattr(self.parameters, "redis_cache_password", None)) self.filter_keys = getattr(self.parameters, "filter_keys", []) self.filter_type = getattr(self.parameters, "filter_type", "whitelist") self.bypass = getattr(self.parameters, "bypass", False) self.timeout = getattr(self.parameters, "timeout", -1) if self.timeout <= 0: raise ConfigurationError( 'Timeout', 'Invalid timeout specified, use positive integer seconds.') self.threshold = getattr(self.parameters, "threshold", -1) if self.threshold <= 0: raise ConfigurationError( 'Threshold', 'Invalid threshold specified, use positive integer count.') self.add_keys = getattr(self.parameters, "add_keys", {})
def init(self): if requests is None: raise MissingDependencyError("requests") self.set_request_parameters() self.http_header['Ocp-Apim-Subscription-Key'] = self.parameters.api_key if self.parameters.file_match: self.file_match = re.compile(self.parameters.file_match) else: self.file_match = None if self.parameters.not_older_than: try: self.time_match = timedelta( minutes=parse_relative(self.parameters.not_older_than)) except ValueError: self.time_match = parser.parse( self.parameters.not_older_than).astimezone(pytz.utc) self.logger.info("Filtering files absolute %r.", self.time_match) self.check_ttl_time() else: self.logger.info("Filtering files relative %r.", self.time_match) if timedelta(seconds=self.parameters.redis_cache_ttl ) < self.time_match: raise ValueError( "The cache's TTL must be higher than 'not_older_than', " "otherwise the bot is processing the same data over and over again." ) else: self.time_match = None self.session = create_request_session(self) self.cache = Cache( self.parameters.redis_cache_host, self.parameters.redis_cache_port, self.parameters.redis_cache_db, self.parameters.redis_cache_ttl, getattr(self.parameters, "redis_cache_password", None))