Ticket #713 (closed defect: fixed)

Opened 8 months ago

Last modified 8 months ago

moto-sync will hang when a RRULE comes up that does not end

Reported by: swolter Owned by: andrewb
Priority: normal Milestone: 0.40
Component: Plugin: moto Version: 0.39
Severity: normal Keywords:
Cc:

Description

When moto-sync encounters an event that will repeat forever, say: RRULE:FREQ=WEEKLY;BYDAY=TH , it will hang for quite a while before reporting an error due to a year overflow. The error is:

Error for entry libkcal-702592820.790 and member 1 (moto-sync): Traceback (most recent call last):
  File "/usr/local/lib/opensync-1.0/python-plugins/motosync.py", line 2319, in commit
    success = self.access.update_entry(change, ctx)
  File "/usr/local/lib/opensync-1.0/python-plugins/motosync.py", line 2172, in update_entry
    entry = PhoneEventSimpleXML(change.data.data)
  File "/usr/local/lib/opensync-1.0/python-plugins/motosync.py", line 1414, in __init__
    rule = xml_rrule_to_moto(rrules, exdates, exrules, self.eventdt, False)
  File "/usr/local/lib/opensync-1.0/python-plugins/motosync.py", line 561, in xml_rrule_to_moto
    ret['repeat_until'] = ruleset[-1]
  File "/var/lib/python-support/python2.4/dateutil/rrule.py", line 147, in __getitem__
    return list(iter(self))[item]
  File "/var/lib/python-support/python2.4/dateutil/rrule.py", line 889, in _iter
    ritem.next()
  File "/var/lib/python-support/python2.4/dateutil/rrule.py", line 838, in next
    self.dt = self.gen()
  File "/var/lib/python-support/python2.4/dateutil/rrule.py", line 508, in _iter
    date = datetime.date.fromordinal(ii.yearordinal+i)
ValueError: year is out of range

Mapping Error: Traceback (most recent call last):
  File "/usr/local/lib/opensync-1.0/python-plugins/motosync.py", line 2319, in commit
    success = self.access.update_entry(change, ctx)
  File "/usr/local/lib/opensync-1.0/python-plugins/motosync.py", line 2172, in update_entry
    entry = PhoneEventSimpleXML(change.data.data)
  File "/usr/local/lib/opensync-1.0/python-plugins/motosync.py", line 1414, in __init__
    rule = xml_rrule_to_moto(rrules, exdates, exrules, self.eventdt, False)
  File "/usr/local/lib/opensync-1.0/python-plugins/motosync.py", line 561, in xml_rrule_to_moto
    ret['repeat_until'] = ruleset[-1]
  File "/var/lib/python-support/python2.4/dateutil/rrule.py", line 147, in __getitem__
    return list(iter(self))[item]
  File "/var/lib/python-support/python2.4/dateutil/rrule.py", line 889, in _iter
    ritem.next()
  File "/var/lib/python-support/python2.4/dateutil/rrule.py", line 838, in next
    self.dt = self.gen()
  File "/var/lib/python-support/python2.4/dateutil/rrule.py", line 508, in _iter
    date = datetime.date.fromordinal(ii.yearordinal+i)
ValueError: year is out of range

This is due to a check in motosync.py:560, where not only the existence of the 'Count' field must be checked, but also if it is not equal to '0':

Index: motosync.py
===================================================================
--- motosync.py (revision 3236)
+++ motosync.py (working copy)
@@ -557,7 +557,7 @@
     ruleset.rrule(xml_rrule_to_dateutil(rulenode, eventdt))
 
     # if the rule ends, get its last occurrence
-    if getXMLField(rulenode, 'Until') or getXMLField(rulenode, 'Count'):
+    if getXMLField(rulenode, 'Until') or (getXMLField(rulenode, 'Count') and getXMLField(rulenode, 'Count') != '0'):
         ret['repeat_until'] = ruleset[-1]
 
     # what events would happen if there were no exceptions?

Change History

Changed 8 months ago by swolter

  • owner changed from dgollub to andrewb
  • component changed from OpenSync to Plugin: moto

Changed 8 months ago by andrewb

  • status changed from new to closed
  • resolution set to fixed

Thanks, although this interpretation (count = 0 means infinite) is quite counterintuitive. Applied as r3240.

Note: See TracTickets for help on using tickets.