You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Database type Country - Blocks IPv4 - Encoding: utf-8
Traceback (most recent call last):
File "./geolite2legacy.py", line 475, in<module>main()
File "./geolite2legacy.py", line 459, in main
r.load(locs, TextIOWrapper(ziparchive.open(blocks, 'r'), encoding='utf-8'))
File "./geolite2legacy.py", line 162, in load
fornets, datain self.gen_nets(locations, outfile):
File "./geolite2legacy.py", line 319, in gen_nets
nets = [IPNetwork(row['network'])]
File "/usr/lib/python2.7/dist-packages/ipaddress.py", line 199, in ip_network
' a unicode object?' % address)
ipaddress.AddressValueError: '1.0.0.0/24' does not appear to be an IPv4 or IPv6 network. Did you pass in a bytes (str in Python 2) instead of a unicode object?
In order to solve this error I've made the following change:
git diff
diff --git a/geolite2legacy.py b/geolite2legacy.py
index e6a39f1..73c3780 100755
--- a/geolite2legacy.py+++ b/geolite2legacy.py@@ -225,7 +225,7 @@ class ASNRadixTree(RadixTree):
def gen_nets(self, locations, infile):
for row in csv.DictReader(infile):
- nets = [IPNetwork(row['network'])]+ nets = [IPNetwork(row['network'].decode('utf-8'))]
org = decode_text(row['autonomous_system_organization'])
asn = row['autonomous_system_number']
entry = u'AS{} {}'.format(asn, org)
@@ -254,7 +254,7 @@ class CityRev1RadixTree(RadixTree):
if location is None:
continue
- nets = [IPNetwork(row['network'])]+ nets = [IPNetwork(row['network'].decode('utf-8'))]
country_iso_code = location['country_iso_code'] or location['continent_code']
fips_code = geoname2fips.get(location['geoname_id'])
if fips_code is None:
@@ -316,7 +316,7 @@ class CountryRadixTree(RadixTree):
if location is None:
continue
- nets = [IPNetwork(row['network'])]+ nets = [IPNetwork(row['network'].decode('utf-8'))]
country_iso_code = location['country_iso_code'] or location['continent_code']
yield nets, (country_iso_code,)
Does this a correct way to solve that issue?
The text was updated successfully, but these errors were encountered:
I'm on fresh Ubuntu Server 20.04. The
python-ipaddress
is installed by the command:But
geolite2legacy.py
returns the following error:In order to solve this error I've made the following change:
Does this a correct way to solve that issue?
The text was updated successfully, but these errors were encountered: