[Erp5-report] r40680 luke - /erp5/trunk/utils/erp5.appliance.test/src/test.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Nov 25 13:48:56 CET 2010
Author: luke
Date: Thu Nov 25 13:48:55 2010
New Revision: 40680
URL: http://svn.erp5.org?rev=40680&view=rev
Log:
- support python versions without scheme
Modified:
erp5/trunk/utils/erp5.appliance.test/src/test.py
Modified: erp5/trunk/utils/erp5.appliance.test/src/test.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.appliance.test/src/test.py?rev=40680&r1=40679&r2=40680&view=diff
==============================================================================
--- erp5/trunk/utils/erp5.appliance.test/src/test.py [utf8] (original)
+++ erp5/trunk/utils/erp5.appliance.test/src/test.py [utf8] Thu Nov 25 13:48:55 2010
@@ -55,9 +55,36 @@ TB_SEP = "==============================
def get_content_type(f):
return mimetypes.guess_type(f.name)[0] or 'application/octet-stream'
+class DummyConn:
+ pass
+
class ConnectionHelper:
+ def _simulateConn(self):
+ # older python, time to simulate
+ conn = DummyConn()
+ conn.scheme = self.conn[0]
+ if '@' in self.conn[1]:
+ user_pass, host_port = self.conn[1].split('@')
+ if ':' in user_pass:
+ conn.username, conn.password = user_pass.split(':')
+ else:
+ conn.username = user_pass, None
+ else:
+ conn.username = None
+ conn.password = None
+ host_port = self.conn[1]
+ if ':' in host_port:
+ conn.hostname, conn.port = host_port.split(':')
+ else:
+ conn.hostname, conn.port = host_port, None
+ conn.path = self.conn[2]
+ self.conn = conn
+
def __init__(self, url):
self.conn = urlparse.urlparse(url)
+ if getattr(self.conn, 'scheme', None) is None \
+ and type(self.conn) in (tuple, list, set):
+ self._simulateConn()
if self.conn.scheme == 'http':
connection_type = httplib.HTTPConnection
if self.conn.port is None:
More information about the Erp5-report
mailing list