Browse Source

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.
master
Julio Biason 15 years ago
parent
commit
35be91a92e
  1. 7
      mitterlib/network/twitter.py
  2. 6
      mitterlib/ui/helpers/gdk_avatarcache.py

7
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))

6
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)

Loading…
Cancel
Save