dh1tw / pyhamtools

A Library with Amateur Radio specific Functions and Methods
MIT License
89 stars 25 forks source link

KeyError: 'Kingdom of Eswatini' #27

Closed sm3ulc closed 6 months ago

sm3ulc commented 10 months ago

Got weird error on first test of example:

Ubuntu 20.04.6 LTS sudo apt install python3-pyhamtools

=>

Python 3.8.10 (default, May 26 2023, 14:05:08) [GCC 9.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. **>>> from pyhamtools import LookupLib, Callinfo

my_lookuplib = LookupLib(lookuptype="countryfile") Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3/dist-packages/pyhamtools/lookuplib.py", line 111, in init self._load_countryfile(cty_file=self._lib_filename) File "/usr/lib/python3/dist-packages/pyhamtools/lookuplib.py", line 1027, in _load_countryfile cty_dict = self._parse_country_file(cty_file, country_mapping_filename) File "/usr/lib/python3/dist-packages/pyhamtools/lookuplib.py", line 1409, in _parse_country_file entry[const.ADIF] = int(mapping[cty_list[item]["Country"]]) KeyError: 'Kingdom of Eswatini'**

dh1tw commented 10 months ago

I just spun up a Docker Container with Ubuntu 20.04. I'm able to confirm the reported bug.

$ apt search pyhamtools
Sorting... Done
Full Text Search... Done
python3-pyhamtools/focal,now 0.7.4-2 all [installed]
  Python library with amateur radio functions and methods

According to the changelog, this bug was fixed in version 0.7.6. I'm not sure if we can fix this bug in the Debian / Ubuntu 20.04 repos. Maybe @df7cb can help out?

Alternatives that come to my mind:

  1. Install the latest version of pyhamtools with the python package manager pip
  2. Upgrade to Ubuntu 22.04 which ships with pyhamtools 0.7.9 (or Debian 12)
  3. Use Docker to spin-up up Ubuntu 22.04 or Debian 12 container
df7cb commented 10 months ago

I have no idea how Ubuntu works there, but on the Debian side, updating old releases is a pretty involved process.

Perhaps the fix for the future could be to make the loader robust so it doesn't die on unknown countries.

dh1tw commented 10 months ago

thanks for the swift answer!

Right - good point to make the loader more robust.

Considering that there are alternatives on how to make pyhamtools work on Ubuntu 20.04 I guess it will remain the way it is. Probably most consumers are anyway already on Debian 12 or a later Ubuntu release.

I thought Ubuntu mainly relies on Debian packages.