diff options
author | Tess Chu <tess@lindenlab.com> | 2007-08-10 02:15:37 +0000 |
---|---|---|
committer | Tess Chu <tess@lindenlab.com> | 2007-08-10 02:15:37 +0000 |
commit | 3b2515fd5ff832fa5faa5384b2c3db919d960509 (patch) | |
tree | 0206223e8f0987dfe07c402c9ca99cee6685a849 /indra/lib/python/indra/ipc | |
parent | 52cb2aea8667056671b67a3c70eeefd00a061751 (diff) |
merge -r 66233:67472 svn+ssh://svn/svn/linden/branches/het-grid-4 Paired by Tess and Leyla.
Added tests to version manager and fixed failed tests. Paired by rdw and Tess.
Diffstat (limited to 'indra/lib/python/indra/ipc')
-rw-r--r-- | indra/lib/python/indra/ipc/httputil.py | 93 | ||||
-rw-r--r-- | indra/lib/python/indra/ipc/llsdhttp.py | 12 | ||||
-rw-r--r-- | indra/lib/python/indra/ipc/mysql_pool.py | 3 |
3 files changed, 14 insertions, 94 deletions
diff --git a/indra/lib/python/indra/ipc/httputil.py b/indra/lib/python/indra/ipc/httputil.py index 85e4a645bc..c4ac0a379d 100644 --- a/indra/lib/python/indra/ipc/httputil.py +++ b/indra/lib/python/indra/ipc/httputil.py @@ -1,94 +1,9 @@ -"""\ -@file httputil.py -@brief HTTP utilities. HTTP date conversion and non-blocking HTTP -client support. -Copyright (c) 2006-2007, Linden Research, Inc. -$License$ -""" +import warnings +warnings.warn("indra.ipc.httputil has been deprecated; use eventlet.httpc instead", DeprecationWarning, 2) -import os -import time -import urlparse +from eventlet.httpc import * -import httplib -try: - from mx.DateTime import Parser - - parse_date = Parser.DateTimeFromString -except ImportError: - from dateutil import parser - - parse_date = parser.parse - - -HTTP_TIME_FORMAT = '%a, %d %b %Y %H:%M:%S GMT' - - -to_http_time = lambda t: time.strftime(HTTP_TIME_FORMAT, time.gmtime(t)) -from_http_time = lambda t: int(parse_date(t).gmticks()) - -def host_and_port_from_url(url): - """@breif Simple function to get host and port from an http url. - @return Returns host, port and port may be None. - """ - host = None - port = None - parsed_url = urlparse.urlparse(url) - try: - host, port = parsed_url[1].split(':') - except ValueError: - host = parsed_url[1].split(':') - return host, port - - -def better_putrequest(self, method, url, skip_host=0): - self.method = method - self.path = url - self.old_putrequest(method, url, skip_host) - - -class HttpClient(httplib.HTTPConnection): - """A subclass of httplib.HTTPConnection which works around a bug - in the interaction between eventlet sockets and httplib. httplib relies - on gc to close the socket, causing the socket to be closed too early. - - This is an awful hack and the bug should be fixed properly ASAP. - """ - def __init__(self, host, port=None, strict=None): - httplib.HTTPConnection.__init__(self, host, port, strict) - - def close(self): - pass - - old_putrequest = httplib.HTTPConnection.putrequest - putrequest = better_putrequest - - -class HttpsClient(httplib.HTTPSConnection): - def close(self): - pass - old_putrequest = httplib.HTTPSConnection.putrequest - putrequest = better_putrequest - - - -scheme_to_factory_map = { - 'http': HttpClient, - 'https': HttpsClient, -} - - -def makeConnection(scheme, location, use_proxy): - if use_proxy: - if "http_proxy" in os.environ: - location = os.environ["http_proxy"] - elif "ALL_PROXY" in os.environ: - location = os.environ["ALL_PROXY"] - else: - location = "localhost:3128" #default to local squid - if location.startswith("http://"): - location = location[len("http://"):] - return scheme_to_factory_map[scheme](location) +makeConnection = make_connection diff --git a/indra/lib/python/indra/ipc/llsdhttp.py b/indra/lib/python/indra/ipc/llsdhttp.py index a2a889742a..fbe08ad7fc 100644 --- a/indra/lib/python/indra/ipc/llsdhttp.py +++ b/indra/lib/python/indra/ipc/llsdhttp.py @@ -1,18 +1,22 @@ """\ @file llsdhttp.py @brief Functions to ease moving llsd over http - + Copyright (c) 2006-2007, Linden Research, Inc. $License$ """ - + import os.path import os import os import urlparse + +from eventlet import httpc as httputil + + + from indra.base import llsd -from indra.ipc import httputil LLSD = llsd.LLSD() @@ -29,7 +33,7 @@ class ConnectionError(Exception): def __str__(self): return "%s(%r, %r, %r, %r, %r, %r, %r)" % ( - type(self).__name__, + self.__class__.__name__, self.method, self.host, self.port, self.path, self.status, self.reason, self.body) diff --git a/indra/lib/python/indra/ipc/mysql_pool.py b/indra/lib/python/indra/ipc/mysql_pool.py index 2bbb60ba0b..2e0c40f850 100644 --- a/indra/lib/python/indra/ipc/mysql_pool.py +++ b/indra/lib/python/indra/ipc/mysql_pool.py @@ -8,7 +8,8 @@ $License$ import os -from eventlet.pools import Pool, DeadProcess +from eventlet.pools import Pool +from eventlet.processes import DeadProcess from indra.ipc import saranwrap import MySQLdb |