# HG changeset patch # User Goffi # Date 1293471476 -3600 # Node ID 5c68a65548c34e6f000631215288cb2e3b8bd863 # Parent b4dfe15c0b251bd47e3279fd9cd380c031039c93 Plugin CS: fixed forgotten debug stuff, CS plugin is now working again User agent changed to "Salut à Toi XMPP/CS Plugin". diff -r b4dfe15c0b25 -r 5c68a65548c3 plugins/plugin_misc_cs.py --- 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)