On 3/14/06, Norman Rasmussen <[EMAIL PROTECTED]> wrote:
> I'm pretty sure that this error is 'left over' from the startup, so
> there's no real stack trace at all.  I think a few sys.exc_clear()'s
> might be in order.  I've found that python doesn't keep track of where
> the exception applies to so well.  I've added the exc_clear's in
> main.py, and we'll see how it goes.

Here's the patch if you're interested:

Index: src/main.py
===================================================================
--- src/main.py (revision 137)
+++ src/main.py (working copy)
@@ -11,16 +11,20 @@
 try:
        from twisted.internet import epollreactor as bestreactor
 except:
+       sys.exc_clear()
        try:
                from twisted.internet import kqreactor as bestreactor
        except:
+               sys.exc_clear()
                try:
                        from twisted.internet import pollreactor as bestreactor
                except:
+                       sys.exc_clear()
                        try:
                                from twisted.internet import
selectreactor as bestreactor
                                print selectWarning
                        except:
+                               sys.exc_clear()
                                try:
                                        from twisted.internet import
default as bestreactor
                                        print selectWarning


--
- Norman Rasmussen
 - Email: [EMAIL PROTECTED]
 - Home page: http://norman.rasmussen.co.za/
From [EMAIL PROTECTED]  Sun Apr 16 14:02:11 2006
From: [EMAIL PROTECTED] (James Bunton)
Date: Sun Apr 16 14:02:19 2006
Subject: [py-transports] PyMSNt: Fix avatars in Google Talk
In-Reply-To: <[EMAIL PROTECTED]>
References: <[EMAIL PROTECTED]>
Message-ID: <[EMAIL PROTECTED]>

On 11/04/2006, at 3:00 AM, Lars T. Mikkelsen wrote:

> As you might know, Google Talk recently got support for vCard-Based
> Avatars. Unfortunately, the avatars won't work with PyMSNt. I've
> attached two patches to fix the issue.
>
> gtalk-avatars-receiving.patch (receiving avatars from MSN users):
> While PyMSNt breaks the base64 encoded avatar data into lines of 76
> characters as recommended by JEP-0153, Section 4.6, Google Talk doesn't
> ignore the whitespace characters as required by the JEP - and thus the
> avatars in Google Talk will be all black. This is clearly a bug in
> Google Talk and I've reported it to Google. This patch is a simple
> workaround that encodes the avatar data without line breaks.
>
> gtalk-avatars-sending.patch (sending avatars to MSN users):
> Google Talk uses XML namespaces for vCard updates, that is:
> <presence>...<upd:x xmlns:upd='vcard-temp:x:update'>...</presence>
> To make PyMSNt correctly detect the namespace, it seems that the
> Element.uri attribute has to be used (and not Element.defaultUri) - I
> don't know the exact difference between uri and defaultUri, but perhaps
> defaultUri should just be replaced with uri throughout the entire 
> source
> code. Furthermore, the Google Talk server won't allow retrieval of the
> vCard, unless the requesting entity has a resource (otherwise a
> resource-constraint error is returned). This patch fixes both issues.
>
> Finally, the Google Talk server seems to do some kind of rate limiting
> on vCard requests. Currently, PyMSNt will make a lot of requests for 
> the
> same vCard. I don't have an exact solution for this, however, I'm
> thinking that it's sufficient to only process presence stanzas to the
> transport itself in jabw.JabberConnection.onPresence() - that is add a
> "if to.find('@') < 0" somewhere in this function. I think it's a 
> general
> (and important) issue if PyMSNt makes more vCard requests than
> necessary, as this requires a lot of bandwith.
>
> Best regards,
> Lars

Thanks for the detailed information.
I've done the first patch slightly differently to maintain 
compatibility with Python 2.3, no b64encode method :(
I also agree that changing defaultUri->uri is a good idea. I need to 
clean up my use of domish.Element in a few places. That's for 0.12.

The transport only does vcard requests when it receives an avatar hash 
that it hasn't cached yet. Have a look in Session.avatarHashReceived, 
it already does check that it isn't a presence to a contact. Could 
Google Talk be incorrectly calculating the hashes?


Could you please apply this patch, then run
$ tail -f debug.log|grep avatarHashReceived

Then muck around with Google Talk for a bit, and the results should 
give us an idea whats going on.
Thanks!

---

James




Index: session.py
===================================================================
--- session.py  (revision 139)
+++ session.py  (working copy)
@@ -182,6 +182,7 @@

         def avatarHashReceived(self, source, dest, avatarHash):
                 if dest.find('@') > 0: return # Ignore presence packets 
sent to users
+               print "avatarHashReceived", source, dest, avatarHash

                 if avatarHash == " ": # Setting no avatar
                         self.legacycon.updateAvatar() # Default
@@ -191,6 +192,7 @@
                                 self.avatar = av # Stuff in the cache 
is always PNG
                                 self.legacycon.updateAvatar(self.avatar)
                         else:
+                               print "avatarHashReceived - retrieving 
vCard"
                                 self.doVCardUpdate()

         def messageReceived(self, source, resource, dest, destr, mtype, 
body, noerror):

Reply via email to