gtg team mailing list archive
-
gtg team
-
Mailing list archive
-
Message #00207
[Merge] lp:~gtg-user/gtg/rtm-sync-plugin into lp:gtg
Luca Invernizzi has proposed merging lp:~gtg-user/gtg/rtm-sync-plugin into lp:gtg.
Requested reviews:
Gtg developers (gtg)
Bug fixing commit:
* On task list with 20 or more elements, rtm server can issue an
incomplete response upon getting the task list. Since urllib was not
reporting the exception, GTG/plugins/rtm_sync/pyrtm/rtm.py was
switched from urllib to httplib. The issue is related to the time
intercurring between two requests, so a simple backoff mechanism was
added
* on task deletion, output on GUI was incorrect
--
https://code.launchpad.net/~gtg-user/gtg/rtm-sync-plugin/+merge/12137
Your team Gtg developers is subscribed to branch lp:gtg.
=== modified file 'GTG/plugins/rtm-sync.gtg-plugin'
--- GTG/plugins/rtm-sync.gtg-plugin 2009-09-12 09:54:39 +0000
+++ GTG/plugins/rtm-sync.gtg-plugin 2009-09-20 14:10:30 +0000
@@ -3,6 +3,6 @@
Name=Remember the milk
Description=Plugin for synchronising Getting Things Gnome! with the web service Remember the milk ( http://www.rememberthemilk.com ).\n\nLegal note: This product uses the Remember The Milk API but is not endorsed or certified by Remember The Milk.
Authors=Luca Invernizzi <invernizzi.l@xxxxxxxxx>
-Version=0.1.1
+Version=0.1.2
Dependencies=python-xml,python-simplejson
Enabled=False
=== modified file 'GTG/plugins/rtm_sync/pyrtm/rtm.py'
--- GTG/plugins/rtm_sync/pyrtm/rtm.py 2009-09-12 14:19:54 +0000
+++ GTG/plugins/rtm_sync/pyrtm/rtm.py 2009-09-20 14:10:30 +0000
@@ -12,8 +12,10 @@
import warnings
import urllib
import logging
+import time
from hashlib import md5
from GTG import _
+import httplib
warnings.simplefilter('default', ImportWarning)
@@ -91,7 +93,7 @@
params['format'] = 'json'
params['api_sig'] = self._sign(params)
- json = openURL(SERVICE_URL, params).read()
+ json = openURL(SERVICE_URL, params)
LOG.debug("JSON response: \n%s" % json)
@@ -178,11 +180,28 @@
for key in keys:
yield key, dictionary[key]
-def openURL(url, queryArgs=None):
+def openURL(url, queryArgs = None):
if queryArgs:
url = url + '?' + urllib.urlencode(queryArgs)
- LOG.debug("URL> %s", url)
- return urllib.urlopen(url)
+ LOG.debug("URL> %s", url)
+ time_to_wait = 0
+ while True:
+ try:
+ if time_to_wait !=0:
+ time.sleep(time_to_wait)
+ http_connection = httplib.HTTPConnection("api.rememberthemilk.com",80)
+ http_connection.request("GET", url)
+ http_response = http_connection.getresponse()
+ http_response_data = http_response.read()
+ break
+ except httplib.IncompleteRead as exception:
+ #rtm server issues incomplete responses if we hammer it too much
+ # this way we can be fast *and* safe
+ if time_to_wait == 0:
+ time_to_wait = 2
+ else:
+ raise exception
+ return http_response_data
class dottedDict(object):
"Make dictionary items accessible via the object-dot notation."
@@ -248,7 +267,7 @@
'getList':
[(), ()],
'removeContact':
- [('timeline', 'group_id', 'contact_id'), ()],
+ [('timeline', 'group_id', 'contact_id'), ()]
},
'lists': {
'add':
=== modified file 'GTG/plugins/rtm_sync/syncengine.py'
--- GTG/plugins/rtm_sync/syncengine.py 2009-09-12 15:09:39 +0000
+++ GTG/plugins/rtm_sync/syncengine.py 2009-09-20 14:10:30 +0000
@@ -93,8 +93,8 @@
self.close_gui(exception.message)
except rtm.RTMError as exception:
self.close_gui(exception.message)
- except:
- self.close_gui(_("Synchronization failed."))
+ except Exception as exception:
+ self.close_gui(_("Synchronization failed." + str(exception)))
def synchronizeWorker(self):
self.update_status(_("Downloading task list..."))
@@ -157,8 +157,9 @@
for gtg_id in gtg_removed:
rtm_id = gtg_to_rtm_id_dict[gtg_id]
rtm_task = filterAttr(self.rtm_list, 'id', rtm_id)
- self.update_substatus(_("Deleting ") + rtm_task.title)
- map(lambda task: task.delete(), rtm_task)
+ if len(rtm_task) > 0:
+ self.update_substatus(_("Deleting ") + rtm_task[0].title)
+ map(lambda task: task.delete(), rtm_task)
#Delete from gtg the tasks that have been removed in rtm
if len(rtm_removed) > 0:
@@ -167,9 +168,10 @@
for rtm_id in rtm_removed:
gtg_id = rtm_to_gtg_id_dict[rtm_id]
gtg_task = filterAttr(self.gtg_list, 'id', gtg_id)
- self.update_substatus(_("Deleting ") + gtg_task.title)
- map(lambda task: task.delete(), gtg_task)
- gtg_common.discard(gtg_id)
+ if len (gtg_task) > 0:
+ self.update_substatus(_("Deleting ") + gtg_task[0].title)
+ map(lambda task: task.delete(), gtg_task)
+ gtg_common.discard(gtg_id)
#tasks that must be added to RTM
#NOTE: should we check if the title is already present in the
Follow ups