ironsheep/RPi-Reporter-MQTT2HA-Daemon

python3 /opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py file

PomeloPomelo opened this issue · 5 comments

Traceback (most recent call last):
File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 1809, in
afterMQTTConnect() # now instead of after?
File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 1799, in afterMQTTConnect
handle_interrupt(0)
File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 1782, in handle_interrupt
update_values()
File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 1765, in update_values
getLastUpdateDate()
File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 1096, in getLastUpdateDate
lines = stdout.decode('utf-8').split("\n")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd4 in position 29: invalid continuation byte
Exception in thread Thread-5:
Traceback (most recent call last):
File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/usr/lib/python3.7/threading.py", line 1166, in run
self.function(*self.args, **self.kwargs)
File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 1490, in periodTimeoutHandler
handle_interrupt(TIMER_INTERRUPT) # '0' means we have a timer interrupt!!!
File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 1782, in handle_interrupt
update_values()
File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 1765, in update_values
getLastUpdateDate()
File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 1096, in getLastUpdateDate
lines = stdout.decode('utf-8').split("\n")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd4 in position 29: invalid continuation byte

Hello, I don't understand why there is such a problem.

Could you grab anything about what this part of the data is.

Somewhere a non-ASCII character is being used, e.g. Cyrillic? which I think 0xd4 might be part of and utf-8 has no idea what to do with it.
What do you get when you type (copy and paste) these at a terminal.
/bin/ls -ltrd /var/lib/apt/lists/partial /var/lib/dpkg/lock

I get

me@mypi:~ $ /bin/ls -ltrd /var/lib/apt/lists/partial /var/lib/dpkg/lock
drwx------ 2 _apt root 4096 Apr 24 14:36 /var/lib/apt/lists/partial
-rw-r----- 1 root root    0 Apr 24 14:39 /var/lib/dpkg/lock

please type what I put, this is what it is failing on and paste the line back, like the 'I get' back (with a code block for bash) or under the <> tool for adding code.

@PomeloPomelo as @bsimmo requested... can you please run:

/bin/ls -ltrd /var/lib/apt/lists/partial /var/lib/dpkg/lock

and reply with the output for us to see.

Oh, one more thing also include the output from $ sudo file /var/lib/dpkg/* /var/lib/apt/lists/partial/*

...mine looks like:

/var/lib/dpkg/alternatives:     directory
/var/lib/dpkg/available:        UTF-8 Unicode text, with very long lines
/var/lib/dpkg/cmethopt:         ASCII text
/var/lib/dpkg/diversions:       ASCII text
/var/lib/dpkg/diversions-old:   ASCII text
/var/lib/dpkg/info:             directory
/var/lib/dpkg/lock:             empty
/var/lib/dpkg/lock-frontend:    empty
/var/lib/dpkg/parts:            directory
/var/lib/dpkg/statoverride:     ASCII text
/var/lib/dpkg/statoverride-old: ASCII text
/var/lib/dpkg/status:           UTF-8 Unicode text, with very long lines
/var/lib/dpkg/status-old:       UTF-8 Unicode text, with very long lines
/var/lib/dpkg/triggers:         directory
/var/lib/dpkg/updates:          directory
/var/lib/apt/lists/partial/*:   cannot open `/var/lib/apt/lists/partial/*' (No such file or directory)

@PomeloPomelo ok, one more thing... please download, unpack, and run the attached file:

locale_test.tar.gz

unpack with:

$ tar -xzvf locale_test.tar.gz

Then run. The output should look something like this:

$ ./locale_test.py 
[2023-05-21 19:13:37] * locale.getpreferredencoding()=[UTF-8]
[2023-05-21 19:13:37] * sys.getfilesystemencoding()=[utf-8]
[2023-05-21 19:13:37] * Done

(This file is now included in the repo as well...)