conduit r1833 - in trunk: . conduit/modules/RTMModule



Author: jstowers
Date: Fri Jan 23 04:50:48 2009
New Revision: 1833
URL: http://svn.gnome.org/viewvc/conduit?rev=1833&view=rev

Log:
2009-01-23  John Stowers  <john stowers gmail com>

	* conduit/modules/RTMModule/RTMModule.py:
	* conduit/modules/RTMModule/rtm.py:
	Make RTMModule not crash hard. Seriously someone needs to finish this

2009-01-23  John Stowers  <john stowers gmail com>

	* conduit/modules/RTMModule/rtm.py:
	Be more flexible with the jsonlib used. Fixes #556892



Modified:
   trunk/ChangeLog
   trunk/conduit/modules/RTMModule/RTMModule.py
   trunk/conduit/modules/RTMModule/rtm.py

Modified: trunk/conduit/modules/RTMModule/RTMModule.py
==============================================================================
--- trunk/conduit/modules/RTMModule/RTMModule.py	(original)
+++ trunk/conduit/modules/RTMModule/RTMModule.py	Fri Jan 23 04:50:48 2009
@@ -44,13 +44,12 @@
     def __init__(self, *args):
         DataProvider.TwoWay.__init__(self)
         self.uids = None
-	self.token = None
         self.tasks = {}
-	self.ical = None
-	self.username = None
-	self.password = None
-	self.rtm = rtm.RTM(apiKey=self.API_KEY,secret=self.SECRET,token=self.get_configuration().get('token'))
-
+        self.ical = None
+        self.username = ""
+        self.password = ""
+        self.token = ""
+        self.rtm = rtm.RTM(apiKey=self.API_KEY,secret=self.SECRET,token=self.get_configuration().get('token'))
 
     def refresh(self):
         DataProvider.TwoWay.refresh(self)
@@ -58,10 +57,10 @@
         tempt = rtm.get_all_tasks(self.rtm)
         #self.tasks.sort(key='id')
         self.ical =open(urllib.urlretrieve('http://%s:%s www rememberthemilk com/icalendar/%s/events/'%(
-	    self.get_configuration().get('username'),
-	    self.get_configuration().get('password'),
-	    self.get_configuration().get('username')))[0]).read()
-	
+        self.get_configuration().get('username'),
+        self.get_configuration().get('password'),
+        self.get_configuration().get('username')))[0]).read()
+    
         for t in tempt:
             self.tasks[t.id] = t
             
@@ -70,8 +69,8 @@
         return list(self.tasks.iterkeys())
 
     def get (self, LUID):
-	log.warn("LUID: %s"%LUID)
-	task = None
+        log.warn("LUID: %s" % LUID)
+        task = None
         if self.tasks.has_key(LUID):
             task = self.tasks[LUID]
         else:
@@ -94,17 +93,13 @@
         del self.tasks[LUID]
     
     def put(self, putData, overwrite, LUID):
-	raise NotImplementedError("Not done")
+        raise NotImplementedError("Not done")
     
     #----------------------------------------------------------------------
     def get_UID(self):
-	""""""
-	return "RTM#%s"%(self.get_configuration().get("username"))
+        return "RTM#%s"%(self.get_configuration().get("username"))
 
     def _login(self):
-        
-	    
-
         if self.token is None:
             # get the ticket and open login url
             #self.token = self.rtm.getToken()
@@ -112,18 +107,17 @@
 
             #wait for log in
             Web.LoginMagic("Log into RememberTheMilk", url, login_function=self._try_login)
+
     def _try_login (self):
         """
         Try to perform a login, return None if it does not succeed
         """
         try:
-	    
             self.token = self.rtm.getToken()
             return self.token
         except:
             return None
 
-    
     def configure(self, window):
         """
         Configures the RTM Backend
@@ -135,8 +129,8 @@
             
         def on_response(sender, responseID):
             if responseID == gtk.RESPONSE_OK:
-		self.username = str(tree.get_widget('user_entry').get_text())
-		self.password = str(tree.get_widget('pass_entry').get_text())
+                self.username = str(tree.get_widget('user_entry').get_text())
+                self.password = str(tree.get_widget('pass_entry').get_text())
                 
         def load_button_clicked(button):
             Utils.dialog_set_busy_cursor(dlg)
@@ -167,9 +161,9 @@
     def get_configuration(self):
         return {
             "token" : self.token,
-	    "username" : self.username,
-	    "password" : self.password
-            }
-	
+            "username" : self.username,
+            "password" : self.password
+        }
+    
   
 

Modified: trunk/conduit/modules/RTMModule/rtm.py
==============================================================================
--- trunk/conduit/modules/RTMModule/rtm.py	(original)
+++ trunk/conduit/modules/RTMModule/rtm.py	Fri Jan 23 04:50:48 2009
@@ -13,12 +13,21 @@
 import urllib
 import logging
 from md5 import md5
-_use_simplejson = False
+
+_use_simplejson = True
 try:
-    import simplejson
-    _use_simplejson = True
-except ImportError:
-    pass
+    import json as simplejson
+    simplejson.loads
+except (ImportError, AttributeError):
+    try:
+        import simplejson
+        simplejson.loads
+    except (ImportError, AttributeError):
+        try:
+            import jsonlib as simplejson
+            simplejson.loads
+        except (ImportError, AttributeError):
+            _use_simplejson = False
 
 LOG = logging.getLogger(__name__)
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]