jwoglom / tconnectsync

Syncs data from Tandem Source (formerly t:connect) to Nightscout for the t:slim X2 and Mobi insulin pumps
MIT License
112 stars 61 forks source link

2.1.0 fails to upload with error in process_user_mode.py #103

Closed Lukazar closed 2 days ago

Lukazar commented 3 days ago

Getting the following error after upgrading to 2.1.0

tconnectsync     | Traceback (most recent call last):
tconnectsync     |   File "/home/appuser/main.py", line 5, in <module>
tconnectsync     |     main()
tconnectsync     |   File "/home/appuser/tconnectsync/__init__.py", line 120, in main
tconnectsync     |     sys.exit(u.process(tconnect, nightscout, time_start, time_end, args.pretend, features=args.features))
tconnectsync     |   File "/home/appuser/tconnectsync/sync/tandemsource/autoupdate.py", line 53, in process
tconnectsync     |     added, event_id = ProcessTimeRange(tconnect, nightscout, tconnectDevice, pretend, features=features).process(time_start, time_end)
tconnectsync     |   File "/home/appuser/tconnectsync/sync/tandemsource/process.py", line 84, in process
tconnectsync     |     ns_entries = c.process(events, events_first_time, events_last_time)
tconnectsync     |   File "/home/appuser/tconnectsync/sync/tandemsource/process_user_mode.py", line 118, in process
tconnectsync     |     ns_entries.append(self.exercise_to_nsentry(start=items[0], stop=items[1], time_end=time_end))
tconnectsync     |   File "/home/appuser/tconnectsync/sync/tandemsource/process_user_mode.py", line 201, in exercise_to_nsentry
tconnectsync     |     duration_mins = (time_end.eventTimestamp - start.eventTimestamp).seconds / 60
tconnectsync     |   File "/base/.venv/lib/python3.9/site-packages/arrow/arrow.py", line 820, in __getattr__
tconnectsync     |     return cast(int, object.__getattribute__(self, name))
tconnectsync     | AttributeError: 'Arrow' object has no attribute 'eventTimestamp'

https://github.com/jwoglom/tconnectsync/blob/master/tconnectsync/sync/tandemsource/process_user_mode.py#L201

Not sure if there is more information I can provide. Thanks again for everything you guys do!

jwoglom commented 3 days ago

Should be fixed in v2.1.1. Good catch!

Lukazar commented 3 days ago

Thanks for the fast response. Looks like the error migrated on us:

tconnectsync     | Traceback (most recent call last):
tconnectsync     |   File "/home/appuser/main.py", line 5, in <module>
tconnectsync     |     main()
tconnectsync     |   File "/home/appuser/tconnectsync/__init__.py", line 120, in main
tconnectsync     |     sys.exit(u.process(tconnect, nightscout, time_start, time_end, args.pretend, features=args.features))
tconnectsync     |   File "/home/appuser/tconnectsync/sync/tandemsource/autoupdate.py", line 53, in process
tconnectsync     |     added, event_id = ProcessTimeRange(tconnect, nightscout, tconnectDevice, pretend, features=features).process(time_start, time_end)
tconnectsync     |   File "/home/appuser/tconnectsync/sync/tandemsource/process.py", line 84, in process
tconnectsync     |     ns_entries = c.process(events, events_first_time, events_last_time)
tconnectsync     |   File "/home/appuser/tconnectsync/sync/tandemsource/process_user_mode.py", line 118, in process
tconnectsync     |     ns_entries.append(self.exercise_to_nsentry(start=items[0], stop=items[1], time_end=time_end))
tconnectsync     |   File "/home/appuser/tconnectsync/sync/tandemsource/process_user_mode.py", line 207, in exercise_to_nsentry
tconnectsync     |     pump_event_id = "%s,%s" % (start.eventId, stop.eventId)
tconnectsync     | AttributeError: 'NoneType' object has no attribute 'eventId'

https://github.com/jwoglom/tconnectsync/blob/master/tconnectsync/sync/tandemsource/process_user_mode.py#L207

Looks like that elseif doesn't have a stop.

Sorry, I'm not a python guy or I'd try to jump in and help. I'd end up doing more harm than good.

jwoglom commented 3 days ago

D'oh, some real brain farts in this section of the code. (why would we read from the stop variable in the "no stop time" section...)

Before rewriting this all to work with Tandem Source I had a good amount of unit tests which would typically catch stuff like this. Hoping to get around to adding those back, just had to rush the implementation of the last bits of this to get over the finish line before the EOL.

Pushed a commit/version to fix this one.

Lukazar commented 2 days ago

Looks good from my end!

D'oh, some real brain farts in this section of the code. (why would we read from the stop variable in the "no stop time" section...)

Ha, we've all been there. You're killing it, thanks for the fast responses.