pyhthon error triggered by calendar.occurrences
Raven24 last edited by
(this is not ‘mission critical’ for us, so I’m writing here instead of opening a ticket)
hello, I’m trying to iterate over events of a specific day in a users calendar, like so
day_start = datetime.strptime('2018-01-01', '%Y-%m-%d') day_end = datetime.strptime('2018-01-31', '%Y-%m-%d') server = kopano.Server(...) calendar = server.user(...).store.calendar for item in calendar.occurrences(day_start, day_end): # do something
the error I’m getting is:
Traceback (most recent call last): File "script.py", line 52, in <module> for item in calendar.occurrences(start_time, end_time): File "/usr/lib/python2.7/dist-packages/kopano/folder.py", line 390, in occurrences for occurrence in self.item(entryid).occurrences(start, end): File "/usr/lib/python2.7/dist-packages/kopano/appointment.py", line 103, in occurrences for occ in self.recurrence.occurrences(start=start, end=end): File "/usr/lib/python2.7/dist-packages/kopano/recurrence.py", line 914, in occurrences recurrences = recurrences.between(_utils._from_gmt(start, tz), _utils._from_gmt(end, tz)) File "/usr/lib/python2.7/dist-packages/kopano/utils.py", line 202, in _from_gmt return date - datetime.timedelta(minutes=_get_timezone(date, tz_data)) File "/usr/lib/python2.7/dist-packages/kopano/utils.py", line 188, in _get_timezone dst = _in_dst(date, dststartmonth, dststartweek, dststarthour, dstendmonth, dstendweek, dstendhour) File "/usr/lib/python2.7/dist-packages/kopano/utils.py", line 164, in _in_dst dststart = datetime.datetime(date.year, dststartmonth, 1) + \ ValueError: month must be in 1..12
I’m on latest kopano 18.104.22.168-0+16.1 supported/stable from the debian repositories
mark dufour last edited by mark dufour
sorry for the late reply.
we recently added a check to 8.6 for when dststartmonth==0, so here it almost has to be larger than 12… :S
would it be possible to give us the value of the local variable ‘tz_data’, as it’s possibly corrupted?
I usually do this by copying /usr/lib/…/kopano locally, and adding a print statement in there.
you could also print(self.subject, self.start) in appointment.py, line 102 or so, to check out which appointment we are dealing with.
PS you can also use datetime(2018, 1, 2) if you’re not aware, so no need for strptime
PS2 user.calendar can also be used instead of user.store.calendar (and anything else this way which is not ambiguous)