From 35be91a92e6ba79aad484e11a44948a744a2a6a1 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Sun, 11 Apr 2010 10:15:11 -0300 Subject: [PATCH] Timeout doesn't exist in Python 2.5, so we wrap it around a try/catch and, in case of exception, we call it without the parameter. --- mitterlib/network/twitter.py | 7 ++++++- mitterlib/ui/helpers/gdk_avatarcache.py | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/mitterlib/network/twitter.py b/mitterlib/network/twitter.py index 7b87131..3bde47a 100644 --- a/mitterlib/network/twitter.py +++ b/mitterlib/network/twitter.py @@ -261,7 +261,12 @@ class Connection(NetworkBase): timeout = self._options['NetworkManager']['timeout'] try: _log.debug('Starting request of %s (timeout %d)' % (url, timeout)) - response = urllib2.urlopen(request, timeout=timeout) + try: + response = urllib2.urlopen(request, timeout=timeout) + except TypeError, e: + # Python 2.5 don't have the timeout parameter. + response = urllib2.urlopen(request) + data = response.read() except urllib2.HTTPError, exc: _log.debug('HTTPError: %d' % (exc.code)) diff --git a/mitterlib/ui/helpers/gdk_avatarcache.py b/mitterlib/ui/helpers/gdk_avatarcache.py index 1c4656e..067b6f4 100644 --- a/mitterlib/ui/helpers/gdk_avatarcache.py +++ b/mitterlib/ui/helpers/gdk_avatarcache.py @@ -96,7 +96,11 @@ class AvatarCache(object): timeout = self._timeout _log.debug('Starting request of %s (timeout %ds)' % ( url, timeout)) - response = urllib2.urlopen(request, timeout=timeout) + try: + response = urllib2.urlopen(request, timeout=timeout) + except TypeError, e: + # Python 2.5 doesn't have a timeout parameter + response = urllib2.urlopen(request) data = response.read() _log.debug('Request completed') return (avatar, owner, data)