cordery / django-countries-plus

Django model & fixture representing all top level country data from Geonames.org
MIT License
45 stars 23 forks source link

update_countries_plus - broken #15

Closed buff0k closed 2 years ago

buff0k commented 2 years ago

I have tested this issue with various python versions and installations (dokku, bare metal, dev and production), and can confirm that python manage.py update_countries_plus fails with following traceback:

python manage.py update_countries_plus Traceback (most recent call last): File "manage.py", line 10, in execute_from_command_line(sys.argv) File "/home/indigo/.pyenv/versions/3.6.5/lib/python3.6/site-packages/django/core/management/init.py", line 381, in execute_from_command_line utility.execute() File "/home/indigo/.pyenv/versions/3.6.5/lib/python3.6/site-packages/django/core/management/init.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/indigo/.pyenv/versions/3.6.5/lib/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv self.execute(*args, *cmd_options) File "/home/indigo/.pyenv/versions/3.6.5/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute output = self.handle(args, **options) File "/home/indigo/.pyenv/versions/3.6.5/lib/python3.6/site-packages/countries_plus/management/commands/update_countries_plus.py", line 10, in handle num_updated, num_created = update_geonames_data() File "/home/indigo/.pyenv/versions/3.6.5/lib/python3.6/site-packages/countries_plus/utils.py", line 218, in update_geonames_data return parse_geonames_data(r.iter_lines()) File "/home/indigo/.pyenv/versions/3.6.5/lib/python3.6/site-packages/countries_plus/utils.py", line 235, in parse_geonames_data if line[0] == "#": IndexError: string index out of range

I suspect a change to geonames.org dataset causes this to fail.

jeyeong commented 2 years ago

I encountered this same issue. It looks like a recent change to the Geonames dataset introduces an empty string when parsing, causing an IndexError when attempting to index the string.

I solved this by introducing a line to parse_geonames_data in utils.py to handle empty strings when parsing the Geonames data.

countries_plus

buff0k commented 2 years ago

Thank you very much @jeyeong , that does solve the problem for now, I suspect an update is needed for dango-countries-plus to include this fix.

cordery commented 2 years ago

Thank you both, resolved in 1.3.2.