changeset 218:5c68a65548c3

Plugin CS: fixed forgotten debug stuff, CS plugin is now working again User agent changed to "Salut à Toi XMPP/CS Plugin".
author Goffi <goffi@goffi.org>
date Mon, 27 Dec 2010 18:37:56 +0100
parents b4dfe15c0b25
children 782319a64ac6
files plugins/plugin_misc_cs.py
diffstat 1 files changed, 6 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/plugin_misc_cs.py	Mon Dec 27 17:23:36 2010 +0100
+++ b/plugins/plugin_misc_cs.py	Mon Dec 27 18:37:56 2010 +0100
@@ -52,7 +52,7 @@
 "description": _(u"""This plugin allow to manage your CouchSurfing account throught your SàT frontend""")
 }
 
-AGENT = 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.3) Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3'
+AGENT = 'Salut à Toi XMPP/CS Plugin'
 
 class CS_Plugin():
 
@@ -73,7 +73,7 @@
         #parameters
         host.memory.importParams(CS_Plugin.params)
         #menu
-        host.importMenu(_("Plugin"), "CouchSurfing", self.menuSelected, help_string = _("Launch CoushSurfing mangement interface"))
+        host.importMenu(_("Plugin"), "CouchSurfing", self.menuSelected, help_string = _("Launch CoushSurfing management interface"))
         self.data=self.host.memory.getPrivate('plugin_cs_data') or {} #TODO: delete cookies/data after a while
         self.host.registerGeneralCB("plugin_CS_sendMessage", self.sendMessage)
         self.host.registerGeneralCB("plugin_CS_showUnreadMessages", self.showUnreadMessages)
@@ -99,27 +99,17 @@
             self.data[profile] = {'cookies':{}}
         else:
             self.data[profile]['cookies'] = {}
-
-
-
-
-   
-        #tmp
-        """f = open('/home/goffi/tmp/CS_principale.html','r')
-        html = f.read()
-        self.__connectionCB(html, id, profile)"""
-
+        
         d = getPage('http://www.couchsurfing.org/login.html', method='POST', postdata=post_data, headers={'Content-Type':'application/x-www-form-urlencoded'} , agent=AGENT, cookies=self.data[profile]['cookies'])
         d.addCallback(self.__connectionCB, id, profile)
         d.addErrback(self.erroCB, id)
 
-
-    #self.host.bridge.actionResult("SUPPRESS", id, {})
+        #self.host.bridge.actionResult("SUPPRESS", id, {})
 
 
 #pages parsing callbacks
     def savePage(self, name, html):
-        f = open ('/home/goffi/tmp/CS_'+name+'.html','w')
+        f = open ('/tmp/CS_'+name+'.html','w')
         f.write(html)
         f.close()
         print "page [%s] sauvee" % name
@@ -127,7 +117,7 @@
 
     def __connectionCB(self, html, id, profile):
         print 'Response received'
-        self.savePage('principale',html)
+        #self.savePage('principale',html)
         soup = BeautifulSoup(html)
         self.data[profile]['user_nick'] = soup.find('a','item_link',href='/home.html').contents[0]
         self.data[profile]['user_name'] = soup.html.head.title.string.split(' - ')[1]
@@ -145,9 +135,6 @@
         #if we have already the list of friend, no need to make new requests
         if not self.data[profile].has_key('friends'):
             self.data[profile]['friends'] = {}
-            """f = open('/home/goffi/tmp/CS_friends.html','r')
-            html = f.read()
-            self.__friendsPageCB(html, id, profile)"""
             d = getPage('http://www.couchsurfing.org/connections.html?type=myfriends&show=10000', agent=AGENT, cookies=self.data[profile]['cookies'])
             d.addCallback(self.__friendsPageCB, id=id, profile=profile)
             d.addErrback(self.erroCB, id)