MQTT Client - TypeError: can't subtract offset-naive and offset-aware datetimes
semuadmin opened this issue · 0 comments
semuadmin commented
pyspartn Bug Report Template
TypeError: can't subtract offset-naive and offset-aware datetimes
when processing basedates without timezone information.
Exception in thread paho-mqtt-client-<<redacted>>:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/threading.py", line 1010, in run
self._target(*self._args, **self._kwargs)
File "/Users/steve/Library/Python/3.12/lib/python/site-packages/paho/mqtt/client.py", line 4523, in _thread_main
self.loop_forever(retry_first_connection=True)
File "/Users/steve/Library/Python/3.12/lib/python/site-packages/paho/mqtt/client.py", line 2297, in loop_forever
rc = self._loop(timeout)
^^^^^^^^^^^^^^^^^^^
File "/Users/steve/Library/Python/3.12/lib/python/site-packages/paho/mqtt/client.py", line 1686, in _loop
rc = self.loop_read()
^^^^^^^^^^^^^^^^
File "/Users/steve/Library/Python/3.12/lib/python/site-packages/paho/mqtt/client.py", line 2100, in loop_read
rc = self._packet_read()
^^^^^^^^^^^^^^^^^^^
File "/Users/steve/Library/Python/3.12/lib/python/site-packages/paho/mqtt/client.py", line 3142, in _packet_read
rc = self._packet_handle()
^^^^^^^^^^^^^^^^^^^^^
File "/Users/steve/Library/Python/3.12/lib/python/site-packages/paho/mqtt/client.py", line 3808, in _packet_handle
return self._handle_publish()
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/steve/Library/Python/3.12/lib/python/site-packages/paho/mqtt/client.py", line 4145, in _handle_publish
self._handle_on_message(message)
File "/Users/steve/Library/Python/3.12/lib/python/site-packages/paho/mqtt/client.py", line 4501, in _handle_on_message
on_message(self, self._userdata, message)
File "/Users/steve/Library/Python/3.12/lib/python/site-packages/pygnssutils/gnssmqttclient.py", line 411, in on_message
for raw, parsed in spr:
File "/Users/steve/Library/Python/3.12/lib/python/site-packages/pyspartn/spartnreader.py", line 135, in __next__
(raw_data, parsed_data) = self.read()
^^^^^^^^^^^
File "/Users/steve/Library/Python/3.12/lib/python/site-packages/pyspartn/spartnreader.py", line 165, in read
(raw_data, parsed_data) = self._parse_spartn(byte1)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/steve/Library/Python/3.12/lib/python/site-packages/pyspartn/spartnreader.py", line 251, in _parse_spartn
parsed_data = self.parse(
^^^^^^^^^^^
File "/Users/steve/Library/Python/3.12/lib/python/site-packages/pyspartn/spartnreader.py", line 328, in parse
return SPARTNMessage(
^^^^^^^^^^^^^^
File "/Users/steve/Library/Python/3.12/lib/python/site-packages/pyspartn/spartnmessage.py", line 98, in __init__
self._do_attributes()
File "/Users/steve/Library/Python/3.12/lib/python/site-packages/pyspartn/spartnmessage.py", line 167, in _do_attributes
iv = self._get_iv()
^^^^^^^^^^^^^^
File "/Users/steve/Library/Python/3.12/lib/python/site-packages/pyspartn/spartnmessage.py", line 203, in _get_iv
timeTag = convert_timetag(self.gnssTimeTag, self._basedate)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/steve/Library/Python/3.12/lib/python/site-packages/pyspartn/spartnhelpers.py", line 282, in convert_timetag
basedate_seconds = date2timetag(basedate)
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/steve/Library/Python/3.12/lib/python/site-packages/pyspartn/spartnhelpers.py", line 245, in date2timetag
return int((date - TIMEBASE).total_seconds())
~~~~~^~~~~~~~~~
TypeError: can't subtract offset-naive and offset-aware datetimes
To Reproduce
Steps to reproduce the behaviour:
- Run
spartn_mqtt_client.py
example with decryption enabled.
Expected Behaviour
- No error.
Desktop (please complete the following information):
- All platforms.
SPARTN data source (please complete the following information as best you can):
- Thingstream PointPerfect MQTT 100H
(NB: Please redact any current SPARTN decryption keys)
Additional context
Add any other context about the problem here.