Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Character Encoding Error in Collector PacketBatchInserter.py #26

Closed
shackrat opened this issue Aug 16, 2022 · 4 comments
Closed

Character Encoding Error in Collector PacketBatchInserter.py #26

shackrat opened this issue Aug 16, 2022 · 4 comments

Comments

@shackrat
Copy link
Contributor

shackrat commented Aug 16, 2022

I have this setup and largely working well in a Ubuntu 20.04 container. Having one issue where it seems the collector is unable to process the UTF-8 characters coming from the aprsc server.

The error is as follows:

root@aprs:~# ~/trackdirect/server/scripts/collector.sh trackdirect.ini 0
/usr/local/lib/python2.7/dist-packages/autobahn/wamp/auth.py:43: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release.
  from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
2022-08-16 14:43:19,682 - trackdirect - WARNING - Starting (Collecting from 192.168.9.90:10152 using N2RWE-S and 10887)
2022-08-16 14:43:19,686 - aprslib.IS - INFO - Attempting connection to 192.168.9.90:10152
2022-08-16 14:43:19,686 - aprslib.IS - INFO - Connected to ('192.168.9.90', 10152)
2022-08-16 14:43:19,711 - aprslib.IS - INFO - Sending login information
2022-08-16 14:43:19,711 - aprslib.IS - INFO - Login successful
2022-08-16 14:43:20,536 - trackdirect.collector.PacketBatchInserter - ERROR - 'ascii' codec can't encode character u'\xe9' in position 85: ordinal not in range(128)
Traceback (most recent call last):
  File "/root/trackdirect/server/trackdirect/collector/PacketBatchInserter.py", line 184, in _insertIntoPacketTable
    "(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", x) for x in datePacketTuples)
  File "/root/trackdirect/server/trackdirect/collector/PacketBatchInserter.py", line 184, in <genexpr>
    "(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", x) for x in datePacketTuples)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 85: ordinal not in range(128)

Locales appear to be set properly for UTF8.

root@aprs:~# locale
LANG=en_US.UTF-8
LANGUAGE=C.UTF-8
LC_CTYPE="C.UTF-8"
LC_NUMERIC="C.UTF-8"
LC_TIME="C.UTF-8"
LC_COLLATE="C.UTF-8"
LC_MONETARY="C.UTF-8"
LC_MESSAGES="C.UTF-8"
LC_PAPER="C.UTF-8"
LC_NAME="C.UTF-8"
LC_ADDRESS="C.UTF-8"
LC_TELEPHONE="C.UTF-8"
LC_MEASUREMENT="C.UTF-8"
LC_IDENTIFICATION="C.UTF-8"
LC_ALL=C.UTF-8

It doesn't matter if I use my own aprsc server or one of the T2 servers. I get the same error so I can safely rule out the server as being the issue.

Unfortunately I am not a Python expert. Could it be that something is be missing in the Python2 setup instructions related to character set?

@shackrat shackrat changed the title Character Encoding Error in Collector.py Character Encoding Error in Collector PacketBatchInserter.py Aug 16, 2022
@shackrat
Copy link
Contributor Author

This was solved. In a normal installation of Postgres the default encoding is set to ASCII. This was raising issues with mogrify which is tied to the character set of the database.

I had to drop the database then alter the CREATE DATABASE statement in the instructions to add ENCODING 'UTF8'

The final statement was:

CREATE DATABASE trackdirect ENCODING 'UTF8';

After that the collectors work.

@nathantcampbell
Copy link

nathantcampbell commented Aug 16, 2022 via email

@shackrat
Copy link
Contributor Author

It's the main branch. It appears that a fresh install of Postgres using the instructions will default to ASCII as the character set. It's necessary to specify encoding when creating the database to get around this. I've created a PR to update the readme as you asked.

Thanks!

@nathantcampbell
Copy link

nathantcampbell commented Aug 18, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants