Update code for Python3

This commit is contained in:
2020-10-30 14:42:56 +01:00
parent 6f9622bb91
commit f457f4e390
11 changed files with 34 additions and 34 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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():