Tertiush / ParadoxIP150v2

Python-based IP150 'middle-ware' that uses the IP module's software port for monitoring and control of the alarm via an MQTT Broker.
Eclipse Public License 1.0
73 stars 35 forks source link

Problem with UTF8 chars #47

Open kosztag opened 3 years ago

kosztag commented 3 years ago

Hi,

I've just run your app first time and tested. The following problem shown and app is crashed when I entered to a zone has non-ascii character in name.

Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "/storage/paradox/ParadoxIP150v2/lib/client.py", line 2291, in _thread_main self.loop_forever() File "/storage/paradox/ParadoxIP150v2/lib/client.py", line 1265, in loop_forever rc = self.loop(timeout, max_packets) File "/storage/paradox/ParadoxIP150v2/lib/client.py", line 831, in loop return self.loop_misc() File "/storage/paradox/ParadoxIP150v2/lib/client.py", line 1130, in loop_misc self._message_retry_check() File "/storage/paradox/ParadoxIP150v2/lib/client.py", line 1862, in _message_retry_check self._message_retry_check_actual(self._out_messages, self._out_message_mutex) File "/storage/paradox/ParadoxIP150v2/lib/client.py", line 1850, in _message_retry_check_actual self._send_publish(m.mid, m.topic, m.payload, m.qos, m.retain, m.dup) File "/storage/paradox/ParadoxIP150v2/lib/client.py", line 1688, in _send_publish utopic = topic.encode('utf-8') UnicodeDecodeError: 'ascii' codec can't decode byte 0x9d in position 16: ordinal not in range(128)

NiOsY commented 2 years ago

just add the following to the beginning of the script:

reload(sys)
sys.setdefaultencoding('latin-1')

this does not solve the utf-8 decode problem, but at least the sctipt does not crash.