Update code for Python3
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
from iwla import IWLA
|
||||
from iplugin import IPlugin
|
||||
|
||||
from iptogeo import IPToGeo
|
||||
from .iptogeo import IPToGeo
|
||||
|
||||
"""
|
||||
Post analysis hook
|
||||
@@ -88,7 +88,7 @@ class IWLAPostAnalysisIPToGeo(IPlugin):
|
||||
geo[cc] += 1
|
||||
else:
|
||||
geo[cc] = 1
|
||||
except Exception, e:
|
||||
print e
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
month_stats['geo'] = geo
|
||||
|
||||
@@ -81,7 +81,7 @@ class IPToGeo(object):
|
||||
return res
|
||||
|
||||
def _create_request(self, ip, ip_type):
|
||||
packet = ''
|
||||
packet = b''
|
||||
packet += struct.pack('<IBBBBI', IPToGeo.MAGIC, IPToGeo.VERSION, IPToGeo.REQ,
|
||||
0, #err
|
||||
ip_type, # ip type
|
||||
@@ -124,7 +124,7 @@ class IPToGeo(object):
|
||||
if not packet:
|
||||
raise socket.timeout
|
||||
return packet
|
||||
except socket.timeout, e:
|
||||
except socket.timeout as e:
|
||||
if second_chance:
|
||||
self._nb_requests_sent = self.MAX_REQUESTS
|
||||
return self._send_request(packet, False)
|
||||
|
||||
@@ -78,7 +78,7 @@ class IWLAPostAnalysisReferers(IPlugin):
|
||||
domain_name = self.iwla.getConfValue('domain_name', '')
|
||||
|
||||
if not domain_name:
|
||||
print 'domain_name must not be empty !'
|
||||
print('domain_name must not be empty !')
|
||||
return False
|
||||
|
||||
self.own_domain_re = re.compile(r'.*%s.*' % (domain_name))
|
||||
@@ -114,7 +114,7 @@ class IWLAPostAnalysisReferers(IPlugin):
|
||||
key_phrase = groups.groupdict()['key_phrase']
|
||||
try:
|
||||
key_phrase = urllib.unquote_plus(key_phrase).decode('utf8')
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
print(e)
|
||||
continue
|
||||
if not key_phrase in key_phrases.keys():
|
||||
|
||||
Reference in New Issue
Block a user