ironsheep / RPi-Reporter-MQTT2HA-Daemon

Linux service to collect and transfer Raspberry Pi data via MQTT to Home Assistant (for RPi Monitoring)
GNU General Public License v3.0
442 stars 62 forks source link

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

Open PomeloPomelo opened 1 year ago

PomeloPomelo commented 1 year ago

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.

bsimmo commented 1 year ago

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
PomeloPomelo commented 1 year ago

Hello, I didn't paste or type anything on the terminal. I just followed the steps on GitHub to deploy the environment and run the program, and then I received the above error message.

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2023年4月24日(星期一) 晚上10:42 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [ironsheep/RPi-Reporter-MQTT2HA-Daemon] python3 /opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py file (Issue #96)

Could you grab at all what this part of 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 type (copy and paste) at a terminal. /bin/ls -ltrd /var/lib/apt/lists/partial /var/lib/dpkg/lock

I get @.:~/RTEllipsoidFit $ /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
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID:
@.>

bsimmo commented 1 year ago

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.

ironsheep commented 1 year ago

@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)
ironsheep commented 1 year ago

@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...)