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 | |
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')
-rw-r--r-- | indra/lib/python/indra/base/llsd.py | 3 | ||||
-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 | ||||
-rw-r--r-- | indra/lib/python/indra/util/llmanifest.py | 19 | ||||
-rw-r--r-- | indra/lib/python/indra/util/llversion.py | 75 |
6 files changed, 106 insertions, 99 deletions
diff --git a/indra/lib/python/indra/base/llsd.py b/indra/lib/python/indra/base/llsd.py index 18e62b0817..462a8787ae 100644 --- a/indra/lib/python/indra/base/llsd.py +++ b/indra/lib/python/indra/base/llsd.py @@ -180,8 +180,9 @@ class LLSDXMLFormatter(object): ''.join(["%s%s" % (self.elt('key', key), self.generate(value)) for key, value in v.items()])) + typeof = type def generate(self, something): - t = type(something) + t = self.typeof(something) if self.type_map.has_key(t): return self.type_map[t](something) else: 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 diff --git a/indra/lib/python/indra/util/llmanifest.py b/indra/lib/python/indra/util/llmanifest.py index 5ab4a892a7..1a9f73a9d9 100644 --- a/indra/lib/python/indra/util/llmanifest.py +++ b/indra/lib/python/indra/util/llmanifest.py @@ -1,4 +1,3 @@ -#!/usr/bin/python """\ @file llmanifest.py @author Ryan Williams @@ -57,7 +56,7 @@ def get_default_platform(dummy): def get_default_version(srctree): # look up llversion.h and parse out the version info - paths = [os.path.join(srctree, x, 'llversion.h') for x in ['llcommon', '../llcommon', '../../indra/llcommon.h']] + paths = [os.path.join(srctree, x, 'llversionviewer.h') for x in ['llcommon', '../llcommon', '../../indra/llcommon.h']] for p in paths: if os.path.exists(p): contents = open(p, 'r').read() @@ -67,6 +66,16 @@ def get_default_version(srctree): build = re.search("LL_VERSION_BUILD\s=\s([0-9]+)", contents).group(1) return major, minor, patch, build +def get_channel(srctree): + # look up llversionserver.h and parse out the version info + paths = [os.path.join(srctree, x, 'llversionviewer.h') for x in ['llcommon', '../llcommon', '../../indra/llcommon.h']] + for p in paths: + if os.path.exists(p): + contents = open(p, 'r').read() + channel = re.search("LL_CHANNEL\s=\s\"([\w\s]+)\"", contents).group(1) + return channel + + DEFAULT_CHANNEL = 'Second Life Release' ARGUMENTS=[ @@ -98,7 +107,7 @@ ARGUMENTS=[ default=""), dict(name='channel', description="""The channel to use for updates.""", - default=DEFAULT_CHANNEL), + default=get_channel), dict(name='installer_name', description=""" The name of the file that the installer should be packaged up into. Only used on Linux at the moment.""", @@ -302,7 +311,9 @@ class LLManifest(object): output = ''.join(lines) status = fd.close() if(status): - raise RuntimeError, "Command " + command + " returned non-zero status (" + str(status) + ")" + raise RuntimeError( + "Command %s returned non-zero status (%s) \noutput:\n%s" + % (command, status, output) ) return output def created_path(self, path): diff --git a/indra/lib/python/indra/util/llversion.py b/indra/lib/python/indra/util/llversion.py new file mode 100644 index 0000000000..5c17bb0fc5 --- /dev/null +++ b/indra/lib/python/indra/util/llversion.py @@ -0,0 +1,75 @@ +"""@file llversion.py +@brief Utility for parsing llcommon/llversion${server}.h + for the version string and channel string + Utility that parses svn info for branch and revision + +Copyright (c) 2006-$CurrentYear$, Linden Research, Inc. +$License$ +""" + +import re, sys, os, commands + +# Methods for gathering version information from +# llversionviewer.h and llversionserver.h + +def get_src_root(): + indra_lib_python_indra_path = os.path.dirname(__file__) + return os.path.abspath(os.path.realpath(indra_lib_python_indra_path + "/../../../../../")) + +def get_version_file_contents(version_type): + filepath = get_src_root() + '/indra/llcommon/llversion%s.h' % version_type + file = open(filepath,"r") + file_str = file.read() + file.close() + return file_str + +def get_version(version_type): + file_str = get_version_file_contents(version_type) + m = re.search('const S32 LL_VERSION_MAJOR = (\d+);', file_str) + VER_MAJOR = m.group(1) + m = re.search('const S32 LL_VERSION_MINOR = (\d+);', file_str) + VER_MINOR = m.group(1) + m = re.search('const S32 LL_VERSION_PATCH = (\d+);', file_str) + VER_PATCH = m.group(1) + m = re.search('const S32 LL_VERSION_BUILD = (\d+);', file_str) + VER_BUILD = m.group(1) + version = "%(VER_MAJOR)s.%(VER_MINOR)s.%(VER_PATCH)s.%(VER_BUILD)s" % locals() + return version + +def get_channel(version_type): + file_str = get_version_file_contents(version_type) + m = re.search('const char \* const LL_CHANNEL = "(.+)";', file_str) + return m.group(1) + +def get_viewer_version(): + return get_version('viewer') + +def get_server_version(): + return get_version('server') + +def get_viewer_channel(): + return get_channel('viewer') + +def get_server_channel(): + return get_channel('server') + +# Methods for gathering subversion information +def get_svn_status_matching(regular_expression): + # Get the subversion info from the working source tree + status, output = commands.getstatusoutput('svn info %s' % get_src_root()) + m = regular_expression.search(output) + if not m: + print "Failed to parse svn info output, resultfollows:" + print output + raise Exception, "No matching svn status in "+src_root + return m.group(1) + +def get_svn_branch(): + branch_re = re.compile('URL: (\S+)') + return get_svn_status_matching(branch_re) + +def get_svn_revision(): + last_rev_re = re.compile('Last Changed Rev: (\d+)') + return get_svn_status_matching(last_rev_re) + + |