|
@@ -84,6 +84,7 @@ def merge_alfred_batman(alfreddata, batmandata):
|
|
|
|
|
|
no_ipblock_resolves_until = None
|
|
|
|
|
|
+
|
|
|
def resolve_ipblock(ipaddr):
|
|
|
"""Resolve the given IP address to its inetnum entry at RIPE."""
|
|
|
global no_ipblock_resolves_until
|
|
@@ -92,7 +93,9 @@ def resolve_ipblock(ipaddr):
|
|
|
if no_ipblock_resolves_until < time.time():
|
|
|
no_ipblock_resolves_until = None
|
|
|
else:
|
|
|
- logger.info('IP-Block-Resolving suspended for {0} seconds. Won\'t resolve \'{1}\' now.'.format(int(no_ipblock_resolves_until-time.time()), ipaddr))
|
|
|
+ logger.info('IP-Block-Resolving suspended for %d seconds. ' +
|
|
|
+ 'Won\'t resolve \'%s\' now.',
|
|
|
+ int(no_ipblock_resolves_until-time.time()), ipaddr)
|
|
|
return None
|
|
|
|
|
|
url = 'http://rest.db.ripe.net/search.json?query-string=' + str(ipaddr)
|
|
@@ -115,12 +118,17 @@ def resolve_ipblock(ipaddr):
|
|
|
|
|
|
except urllib2.URLError as err:
|
|
|
output = err.read()
|
|
|
- logger.error('Error "{1}" querying ip \'{0}\' from RIPE API: {2}'.format(ipaddr, err, output))
|
|
|
+ logger.error('Error "%s" querying ip \'%s\' from RIPE API: %s',
|
|
|
+ err, ipaddr, output)
|
|
|
if 'Retry-After' in err.headers:
|
|
|
retry = int(err.headers['Retry-After'])
|
|
|
- logger.warn('I won\'t resolve IPs for {0} seconds as requested by RIPE API (header=\'{1}\').'.format(retry, err.header['Retry-After']))
|
|
|
- no_ipblock_resolves_until = time.time() + int(err.headers['Retry-After'])
|
|
|
+ logger.warn(
|
|
|
+ 'I won\'t resolve IPs for %d seconds as requested by RIPE API' +
|
|
|
+ ' (header=\'%s\').',
|
|
|
+ retry, err.header['Retry-After'])
|
|
|
+ no_ipblock_resolves_until = \
|
|
|
+ time.time() + int(err.headers['Retry-After'])
|
|
|
else:
|
|
|
- logger.warn('I won\'t resolve IPs for the next hour (API didn\'t give better hint).')
|
|
|
+ logger.warn('I won\'t resolve IPs for the next hour ' +
|
|
|
+ '(API didn\'t give better hint).')
|
|
|
no_ipblock_resolves_until = time.time() + 3600
|
|
|
-
|