tags 461148 patch upstream thanks [ Vincent Bernat ] > Proxy support using http_proxy environment variable seems broken. Boto > seems to wait http_proxy as "proxy:port", while the form of this > variable is usually "http://proxy:port". Since it splits on ":", it > gets a 3-tuple instead of a 2-tuple. > > Moreover, this variable can be empty. In this case, we get an > exception because Boto tries to access to > os.environ['http_proxy'].split(':')[1].
Hi Vincent, I've submitted a bug upstream[1] and included the attached patch. If you have the opportunity to try out the patch, please update the bug report and let me know if there are any problems. Thanks for the report. [1] http://code.google.com/p/boto/issues/detail?id=90 -- Eric Evans [EMAIL PROTECTED]
Index: boto/connection.py
===================================================================
--- boto.orig/connection.py 2008-01-21 10:58:59.000000000 -0600
+++ boto/connection.py 2008-01-21 12:11:46.000000000 -0600
@@ -58,6 +58,8 @@
proxy=None, proxy_port=None, debug=False,
https_connection_factory=None):
self.is_secure = is_secure
+ self.proxy = proxy
+ self.proxy_port = proxy_port
# define exceptions from httplib that we want to catch and retry
self.http_exceptions = (httplib.HTTPException, socket.error,
socket.gaierror)
# define values in socket exceptions we don't want to catch
@@ -90,29 +92,26 @@
if os.environ.has_key('AWS_SECRET_ACCESS_KEY'):
self.aws_secret_access_key =
os.environ['AWS_SECRET_ACCESS_KEY']
- self.proxy = proxy
#This lowercase environment var is the same as used in urllib
- if os.environ.has_key('http_proxy'):
- proxy_port_pair = os.environ['http_proxy'].split(':')
- self.proxy = proxy_port_pair[0]
+ if os.environ.has_key('http_proxy') and not self.proxy:
+ http_proxy = os.environ['http_proxy'].replace('http://', '')
+ proxy_port_pair = http_proxy.split(':')
+ if proxy_port_pair[0]:
+ self.proxy = proxy_port_pair[0]
+
+ if not self.proxy_port and self.proxy:
+ if proxy_port_pair[1]:
+ self.proxy_port = proxy_port_pair[1]
+ else:
+ print "http_proxy environment variable does not specify " \
+ "a port, using default"
+ self.proxy_port = self.port
+
self.use_proxy = (self.proxy != None)
if (self.use_proxy and self.is_secure):
raise AWSConnectionError("Unable to provide secure connection
through proxy")
- if proxy_port:
- self.proxy_port = proxy_port
- else:
- if os.environ.has_key('http_proxy'):
- proxy_port_pair = os.environ['http_proxy'].split(':')[1]
- if len(proxy_port_pair) != 2:
- print "http_proxy env var does not specify port, using
default"
- self.proxy_port = self.port
- else:
- self.proxy_port = proxy_port_pair[1]
- else:
- self.proxy_port = None
-
self.make_http_connection()
self._last_rs = None
signature.asc
Description: Digital signature

