From 5f4c09fa1f4b09126e1a16e78044c64e97828530 Mon Sep 17 00:00:00 2001 From: Bryan O'Sullivan Date: Mon, 22 Jun 2009 22:36:36 +0000 Subject: Python 2.4 and 2.6 improvements The sets module is no longer needed with Python 2.4, and causes a DeprecationWarning with 2.6, so drop it The md5 module causes a DeprecationWarning with 2.6, so try to import hashlib (its replacement) instead, else fall back Reviewed by Poppy. --- indra/lib/python/indra/base/lluuid.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'indra/lib') diff --git a/indra/lib/python/indra/base/lluuid.py b/indra/lib/python/indra/base/lluuid.py index aceea29cd2..1cdd8e915b 100644 --- a/indra/lib/python/indra/base/lluuid.py +++ b/indra/lib/python/indra/base/lluuid.py @@ -26,8 +26,14 @@ THE SOFTWARE. $/LicenseInfo$ """ -import md5, random, socket, string, time, re +import random, socket, string, time, re import uuid +try: + # Python 2.6 + from hashlib import md5 +except ImportError: + # Python 2.5 and earlier + from md5 import new as md5 def _int2binstr(i,l): s='' @@ -196,7 +202,7 @@ class UUID(object): from c++ implementation for portability reasons. Returns self. """ - m = md5.new() + m = md5() m.update(uuid.uuid1().bytes) self._bits = m.digest() return self -- cgit v1.2.3 From e588d1f28419745ee1e1ee98dc1852e0364a4088 Mon Sep 17 00:00:00 2001 From: Christian Goetze Date: Wed, 1 Jul 2009 00:22:05 +0000 Subject: svn merge -r125825:125901 svn+ssh://svn.lindenlab.com/svn/user/cg/qar-1654 QAR-1654 merge completed. --- indra/lib/python/indra/base/llsd.py | 2 +- indra/lib/python/indra/util/llsubprocess.py | 11 +++++++++++ indra/lib/python/indra/util/named_query.py | 4 ++-- 3 files changed, 14 insertions(+), 3 deletions(-) (limited to 'indra/lib') diff --git a/indra/lib/python/indra/base/llsd.py b/indra/lib/python/indra/base/llsd.py index 1190d88663..4527b115f9 100644 --- a/indra/lib/python/indra/base/llsd.py +++ b/indra/lib/python/indra/base/llsd.py @@ -238,7 +238,7 @@ class LLSDXMLFormatter(object): def MAP(self, v): return self.elt( 'map', - ''.join(["%s%s" % (self.elt('key', key), self.generate(value)) + ''.join(["%s%s" % (self.elt('key', self.xml_esc(str(key))), self.generate(value)) for key, value in v.items()])) typeof = type diff --git a/indra/lib/python/indra/util/llsubprocess.py b/indra/lib/python/indra/util/llsubprocess.py index c4c40739ec..7e0e115d14 100644 --- a/indra/lib/python/indra/util/llsubprocess.py +++ b/indra/lib/python/indra/util/llsubprocess.py @@ -90,6 +90,17 @@ all the output, and get the result. child.tochild.close() result = child.poll() if result != -1: + # At this point, the child process has exited and result + # is the return value from the process. Between the time + # we called select() and poll() the process may have + # exited so read all the data left on the child process + # stdout and stderr. + last = child.fromchild.read() + if last: + out.append(last) + last = child.childerr.read() + if last: + err.append(last) child.tochild.close() child.fromchild.close() child.childerr.close() diff --git a/indra/lib/python/indra/util/named_query.py b/indra/lib/python/indra/util/named_query.py index 693b483f79..5c19368240 100644 --- a/indra/lib/python/indra/util/named_query.py +++ b/indra/lib/python/indra/util/named_query.py @@ -48,8 +48,8 @@ from indra.base import llsd from indra.base import config DEBUG = False -NQ_FILE_SUFFIX = None -NQ_FILE_SUFFIX_LEN = None +NQ_FILE_SUFFIX = config.get('named-query-file-suffix', '.nq') +NQ_FILE_SUFFIX_LEN = len(NQ_FILE_SUFFIX) _g_named_manager = None -- cgit v1.2.3 From ff11d74820c89822cd067b51727d9df1dc87d0d0 Mon Sep 17 00:00:00 2001 From: Bryan O'Sullivan Date: Wed, 26 Aug 2009 10:57:38 -0700 Subject: Add Mercurial-specific build version info. Pilfered from billc. --- indra/lib/python/indra/util/llversion.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'indra/lib') diff --git a/indra/lib/python/indra/util/llversion.py b/indra/lib/python/indra/util/llversion.py index 770b861ddc..c48ab679f4 100644 --- a/indra/lib/python/indra/util/llversion.py +++ b/indra/lib/python/indra/util/llversion.py @@ -1,7 +1,7 @@ """@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 + Utility that parses hg or svn info for branch and revision $LicenseInfo:firstyear=2006&license=mit$ @@ -79,8 +79,8 @@ def get_svn_status_matching(regular_expression): 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 + print >> sys.stderr, "Failed to parse svn info output, result follows:" + print >> sys.stderr, output raise Exception, "No matching svn status in "+src_root return m.group(1) @@ -92,4 +92,25 @@ def get_svn_revision(): last_rev_re = re.compile('Last Changed Rev: (\d+)') return get_svn_status_matching(last_rev_re) - +def get_hg_repo(): + status, output = commands.getstatusoutput('hg showconfig paths.default') + if status: + print >> sys.stderr, output + sys.exit(1) + if not output: + print >> sys.stderr, 'ERROR: cannot find repo we cloned from' + sys.exit(1) + return output + +def get_hg_changeset(): + status, output = commands.getstatusoutput('hg id -i') + if status: + print >> sys.stderr, output + sys.exit(1) + return output + +def using_svn(): + return os.path.isdir(os.path.join(get_src_root(), '.svn')) + +def using_hg(): + return os.path.isdir(os.path.join(get_src_root(), '.hg')) -- cgit v1.2.3 From 5f3a7fa6f3ba45d875ec437c5df9e712f3c6b5a2 Mon Sep 17 00:00:00 2001 From: Bryan O'Sullivan Date: Tue, 1 Sep 2009 11:18:33 -0700 Subject: Patch in some other useful scripts from trunk. --- indra/lib/python/indra/util/llversion.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'indra/lib') diff --git a/indra/lib/python/indra/util/llversion.py b/indra/lib/python/indra/util/llversion.py index 770b861ddc..c48ab679f4 100644 --- a/indra/lib/python/indra/util/llversion.py +++ b/indra/lib/python/indra/util/llversion.py @@ -1,7 +1,7 @@ """@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 + Utility that parses hg or svn info for branch and revision $LicenseInfo:firstyear=2006&license=mit$ @@ -79,8 +79,8 @@ def get_svn_status_matching(regular_expression): 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 + print >> sys.stderr, "Failed to parse svn info output, result follows:" + print >> sys.stderr, output raise Exception, "No matching svn status in "+src_root return m.group(1) @@ -92,4 +92,25 @@ def get_svn_revision(): last_rev_re = re.compile('Last Changed Rev: (\d+)') return get_svn_status_matching(last_rev_re) - +def get_hg_repo(): + status, output = commands.getstatusoutput('hg showconfig paths.default') + if status: + print >> sys.stderr, output + sys.exit(1) + if not output: + print >> sys.stderr, 'ERROR: cannot find repo we cloned from' + sys.exit(1) + return output + +def get_hg_changeset(): + status, output = commands.getstatusoutput('hg id -i') + if status: + print >> sys.stderr, output + sys.exit(1) + return output + +def using_svn(): + return os.path.isdir(os.path.join(get_src_root(), '.svn')) + +def using_hg(): + return os.path.isdir(os.path.join(get_src_root(), '.hg')) -- cgit v1.2.3 From dd628f29af0fcd0ec5f62ee71fc201c1e523a32a Mon Sep 17 00:00:00 2001 From: Bryan O'Sullivan Date: Tue, 1 Sep 2009 11:54:34 -0700 Subject: Use rev numbers instead of changeset IDs for now. --- indra/lib/python/indra/util/llversion.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'indra/lib') diff --git a/indra/lib/python/indra/util/llversion.py b/indra/lib/python/indra/util/llversion.py index c48ab679f4..2718a85f41 100644 --- a/indra/lib/python/indra/util/llversion.py +++ b/indra/lib/python/indra/util/llversion.py @@ -103,11 +103,21 @@ def get_hg_repo(): return output def get_hg_changeset(): - status, output = commands.getstatusoutput('hg id -i') + # The right thing to do: + # status, output = commands.getstatusoutput('hg id -i') + # if status: + # print >> sys.stderr, output + # sys.exit(1) + + # The temporary hack: + status, output = commands.getstatusoutput('hg parents --template "{rev}"') if status: print >> sys.stderr, output sys.exit(1) - return output + lines = output.splitlines() + if len(lines) > 1: + print >> sys.stderr, 'ERROR: working directory has %d parents' % len(lines) + return lines[0] def using_svn(): return os.path.isdir(os.path.join(get_src_root(), '.svn')) -- cgit v1.2.3 From 93869a8ef23bd07351309ed86e10a0acd66ae973 Mon Sep 17 00:00:00 2001 From: "Mark Palange (Mani)" Date: Tue, 15 Sep 2009 12:32:22 -0700 Subject: Fixed up CopyWinLibs.cmake post moap/viewer-2.0.0-3 merge. Added CRT assembly check to viewer_manifest.py. twiddled test_win32_manifest.py for ease of use. --- indra/lib/python/indra/util/test_win32_manifest.py | 126 +++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 indra/lib/python/indra/util/test_win32_manifest.py (limited to 'indra/lib') diff --git a/indra/lib/python/indra/util/test_win32_manifest.py b/indra/lib/python/indra/util/test_win32_manifest.py new file mode 100644 index 0000000000..7aa7a10928 --- /dev/null +++ b/indra/lib/python/indra/util/test_win32_manifest.py @@ -0,0 +1,126 @@ +# @file test_win32_manifest.py +# @brief Test an assembly binding version and uniqueness in a windows dll or exe. +# +# $LicenseInfo:firstyear=2009&license=viewergpl$ +# +# Copyright (c) 2009, Linden Research, Inc. +# +# Second Life Viewer Source Code +# The source code in this file ("Source Code") is provided by Linden Lab +# to you under the terms of the GNU General Public License, version 2.0 +# ("GPL"), unless you have obtained a separate licensing agreement +# ("Other License"), formally executed by you and Linden Lab. Terms of +# the GPL can be found in doc/GPL-license.txt in this distribution, or +# online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 +# +# There are special exceptions to the terms and conditions of the GPL as +# it is applied to this Source Code. View the full text of the exception +# in the file doc/FLOSS-exception.txt in this software distribution, or +# online at +# http://secondlifegrid.net/programs/open_source/licensing/flossexception +# +# By copying, modifying or distributing this software, you acknowledge +# that you have read and understood your obligations described above, +# and agree to abide by those obligations. +# +# ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO +# WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, +# COMPLETENESS OR PERFORMANCE. +# $/LicenseInfo$ + +import sys, os +import tempfile +from xml.dom.minidom import parse + +def get_HKLM_registry_value(key_str, value_str): + import _winreg + reg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE) + key = _winreg.OpenKey(reg, key_str) + value = _winreg.QueryValueEx(key, value_str)[0] + print 'Found: %s' % value + return value + +def find_vc_dir(): + supported_versions = (r'8.0', r'9.0') + value_str = (r'ProductDir') + + for version in supported_versions: + key_str = (r'SOFTWARE\Microsoft\VisualStudio\%s\Setup\VC' % + version) + try: + return get_HKLM_registry_value(key_str, value_str) + except WindowsError, err: + x64_key_str = (r'SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%s\Setup\VS' % + version) + try: + return get_HKLM_registry_value(x64_key_str, value_str) + except: + print >> sys.stderr, "Didn't find MS VC version %s " % version + + raise + +def find_mt_path(): + vc_dir = find_vc_dir() + mt_path = '\"%sbin\\mt.exe\"' % vc_dir + return mt_path + +def test_assembly_binding(src_filename, assembly_name, assembly_ver): + (tmp_file_fd, tmp_file_name) = tempfile.mkstemp(suffix='.xml') + tmp_file = os.fdopen(tmp_file_fd) + tmp_file.close() + + mt_path = find_mt_path() + resource_id = "" + if os.path.splitext(src_filename)[1].lower() == ".dll": + resource_id = ";#2" + system_call = '%s -nologo -inputresource:%s%s -out:%s' % (mt_path, src_filename, resource_id, tmp_file_name) + print "Executing: %s" % system_call + os.system(system_call) + + manifest_dom = parse(tmp_file_name) + nodes = manifest_dom.getElementsByTagName('assemblyIdentity') + + versions = list() + for node in nodes: + if node.getAttribute('name') == assembly_name: + versions.append(node.getAttribute('version')) + + if len(versions) == 0: + print "No manifest found for %s" % src_filename + + elif len(versions) > 1: + print "Multiple bindings to %s found:" % assembly_name + print versions + print + raise Exception("Multiple bindings") + + elif versions[0] != assembly_ver: + print "Unexpected version found for %s:" % assembly_name + print "Wanted %s, found %s" % (assembly_ver, versions[0]) + print + raise Exception("Unexpected version") + + os.remove(tmp_file_name) + + +if __name__ == '__main__': + + print "Running test_win32_manifest.py..." + print + + usage = 'test_win32_manfest ' + + try: + src_filename = sys.argv[1] + assembly_name = sys.argv[2] + assembly_ver = sys.argv[3] + except: + print "Usage:" + print usage + print + raise + + test_assembly_binding(src_filename, assembly_name, assembly_ver) + + + -- cgit v1.2.3 From afb053ebd7c50482088ea2ddf585efe8446969cf Mon Sep 17 00:00:00 2001 From: brad kittenbrink Date: Fri, 18 Sep 2009 19:30:10 -0400 Subject: Minor tweaks of test_win32_manifest output. --- indra/lib/python/indra/util/test_win32_manifest.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'indra/lib') diff --git a/indra/lib/python/indra/util/test_win32_manifest.py b/indra/lib/python/indra/util/test_win32_manifest.py index 7aa7a10928..460e5fd487 100644 --- a/indra/lib/python/indra/util/test_win32_manifest.py +++ b/indra/lib/python/indra/util/test_win32_manifest.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python # @file test_win32_manifest.py # @brief Test an assembly binding version and uniqueness in a windows dll or exe. # @@ -37,21 +38,21 @@ def get_HKLM_registry_value(key_str, value_str): reg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE) key = _winreg.OpenKey(reg, key_str) value = _winreg.QueryValueEx(key, value_str)[0] - print 'Found: %s' % value + #print 'Found: %s' % value return value def find_vc_dir(): supported_versions = (r'8.0', r'9.0') value_str = (r'ProductDir') - for version in supported_versions: + for version in supported_versions: key_str = (r'SOFTWARE\Microsoft\VisualStudio\%s\Setup\VC' % version) try: - return get_HKLM_registry_value(key_str, value_str) + return get_HKLM_registry_value(key_str, value_str) except WindowsError, err: x64_key_str = (r'SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%s\Setup\VS' % - version) + version) try: return get_HKLM_registry_value(x64_key_str, value_str) except: @@ -65,6 +66,8 @@ def find_mt_path(): return mt_path def test_assembly_binding(src_filename, assembly_name, assembly_ver): + print "checking %s dependency %s..." % (src_filename, assembly_name) + (tmp_file_fd, tmp_file_name) = tempfile.mkstemp(suffix='.xml') tmp_file = os.fdopen(tmp_file_fd) tmp_file.close() @@ -101,12 +104,15 @@ def test_assembly_binding(src_filename, assembly_name, assembly_ver): raise Exception("Unexpected version") os.remove(tmp_file_name) + + print "SUCCESS: %s OK!" % src_filename + print if __name__ == '__main__': - print "Running test_win32_manifest.py..." print + print "Running test_win32_manifest.py..." usage = 'test_win32_manfest ' @@ -121,6 +127,5 @@ if __name__ == '__main__': raise test_assembly_binding(src_filename, assembly_name, assembly_ver) - -- cgit v1.2.3 From 17f9fd5f9653077b6059b34147a447310a30daec Mon Sep 17 00:00:00 2001 From: "Mark Palange (Mani)" Date: Fri, 25 Sep 2009 19:23:24 -0700 Subject: Changes force no crt manifest linking in windows plugin files. --- indra/lib/python/indra/util/test_win32_manifest.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'indra/lib') diff --git a/indra/lib/python/indra/util/test_win32_manifest.py b/indra/lib/python/indra/util/test_win32_manifest.py index 460e5fd487..75473ff55f 100644 --- a/indra/lib/python/indra/util/test_win32_manifest.py +++ b/indra/lib/python/indra/util/test_win32_manifest.py @@ -78,7 +78,10 @@ def test_assembly_binding(src_filename, assembly_name, assembly_ver): resource_id = ";#2" system_call = '%s -nologo -inputresource:%s%s -out:%s' % (mt_path, src_filename, resource_id, tmp_file_name) print "Executing: %s" % system_call - os.system(system_call) + mt_result = os.system(system_call) + if mt_result == 31: + print "No manifest found in %s" % src_filename + raise Exception("No manifest found") manifest_dom = parse(tmp_file_name) nodes = manifest_dom.getElementsByTagName('assemblyIdentity') @@ -89,7 +92,8 @@ def test_assembly_binding(src_filename, assembly_name, assembly_ver): versions.append(node.getAttribute('version')) if len(versions) == 0: - print "No manifest found for %s" % src_filename + print "No matching assemblies found in %s" % src_filename + raise Exception("No matching assembly") elif len(versions) > 1: print "Multiple bindings to %s found:" % assembly_name @@ -108,7 +112,6 @@ def test_assembly_binding(src_filename, assembly_name, assembly_ver): print "SUCCESS: %s OK!" % src_filename print - if __name__ == '__main__': print -- cgit v1.2.3 From 292aecbb3e14658c470978efeb7cd790ec156fd2 Mon Sep 17 00:00:00 2001 From: brad kittenbrink Date: Wed, 30 Sep 2009 18:57:00 -0700 Subject: Updated test_win32_manifest.py to throw custom exception objects, rather than relying on string comparison. --- indra/lib/python/indra/util/test_win32_manifest.py | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'indra/lib') diff --git a/indra/lib/python/indra/util/test_win32_manifest.py b/indra/lib/python/indra/util/test_win32_manifest.py index 75473ff55f..0a2ebc48d4 100644 --- a/indra/lib/python/indra/util/test_win32_manifest.py +++ b/indra/lib/python/indra/util/test_win32_manifest.py @@ -33,6 +33,21 @@ import sys, os import tempfile from xml.dom.minidom import parse +class AssemblyTestException(Exception): + pass + +class NoManifestException(AssemblyTestException): + pass + +class MultipleBindingsException(AssemblyTestException): + pass + +class UnexpectedVersionException(AssemblyTestException): + pass + +class NoMatchingAssemblyException(AssemblyTestException): + pass + def get_HKLM_registry_value(key_str, value_str): import _winreg reg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE) @@ -81,7 +96,7 @@ def test_assembly_binding(src_filename, assembly_name, assembly_ver): mt_result = os.system(system_call) if mt_result == 31: print "No manifest found in %s" % src_filename - raise Exception("No manifest found") + raise NoManifestException() manifest_dom = parse(tmp_file_name) nodes = manifest_dom.getElementsByTagName('assemblyIdentity') @@ -93,19 +108,19 @@ def test_assembly_binding(src_filename, assembly_name, assembly_ver): if len(versions) == 0: print "No matching assemblies found in %s" % src_filename - raise Exception("No matching assembly") + raise NoMatchingAssemblyException() elif len(versions) > 1: print "Multiple bindings to %s found:" % assembly_name print versions print - raise Exception("Multiple bindings") + raise MultipleBindingsException(versions) elif versions[0] != assembly_ver: print "Unexpected version found for %s:" % assembly_name print "Wanted %s, found %s" % (assembly_ver, versions[0]) print - raise Exception("Unexpected version") + raise UnexpectedVersionException(assembly_ver, versions[0]) os.remove(tmp_file_name) -- cgit v1.2.3 From 0d0840de0e9039e3e5b2fd3261b8ed2b5efba567 Mon Sep 17 00:00:00 2001 From: "Mark Palange (Mani)" Date: Thu, 1 Oct 2009 14:51:35 -0700 Subject: Routing mt.exe output to NUL to hopefully fix expected error build failures... --- indra/lib/python/indra/util/test_win32_manifest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/lib') diff --git a/indra/lib/python/indra/util/test_win32_manifest.py b/indra/lib/python/indra/util/test_win32_manifest.py index 0a2ebc48d4..0149b9f43a 100644 --- a/indra/lib/python/indra/util/test_win32_manifest.py +++ b/indra/lib/python/indra/util/test_win32_manifest.py @@ -91,7 +91,7 @@ def test_assembly_binding(src_filename, assembly_name, assembly_ver): resource_id = "" if os.path.splitext(src_filename)[1].lower() == ".dll": resource_id = ";#2" - system_call = '%s -nologo -inputresource:%s%s -out:%s' % (mt_path, src_filename, resource_id, tmp_file_name) + system_call = '%s -nologo -inputresource:%s%s -out:%s > NUL' % (mt_path, src_filename, resource_id, tmp_file_name) print "Executing: %s" % system_call mt_result = os.system(system_call) if mt_result == 31: -- cgit v1.2.3