From 680194deaf7a35caaa629abc16e886d71baff636 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Fri, 21 Nov 2014 18:09:12 -0500 Subject: automate keeping the About SL -> Licenses tab correct --- scripts/packages-formatter.py | 73 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100755 scripts/packages-formatter.py (limited to 'scripts') diff --git a/scripts/packages-formatter.py b/scripts/packages-formatter.py new file mode 100755 index 0000000000..1432cdaebe --- /dev/null +++ b/scripts/packages-formatter.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python +"""\ +This module formats the package version and copyright information for the +viewer and its dependent packages. + +$LicenseInfo:firstyear=2014&license=viewerlgpl$ +Second Life Viewer Source Code +Copyright (C) 2014, Linden Research, Inc. + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; +version 2.1 of the License only. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +$/LicenseInfo$ +""" +import os +import sys +import re +import subprocess + +autobuild=os.getenv('AUTOBUILD', + 'autobuild' if not ( sys.platform == 'win32' or sys.platform == 'cygwin') + else 'autobuild.cmd') + +pkg_line=re.compile('^([\w-]+):\s+(.*)$') + +version={} +versions=subprocess.Popen([autobuild, 'install', '--versions'], + stdin=None, stdout=subprocess.PIPE, universal_newlines=True).stdout +for line in versions: + pkg_info = pkg_line.match(line) + if pkg_info: + pkg = pkg_info.group(1) + if pkg not in version: + version[pkg] = pkg_info.group(2).strip() + else: + sys.exit("Duplicate version for %s" % pkg) + else: + sys.exit("Unrecognized --versions output: %s" % line) + +copyright={} +copyrights=subprocess.Popen([autobuild, 'install', '--copyrights'], + stdin=None, stdout=subprocess.PIPE, universal_newlines=True).stdout +viewer_copyright = copyrights.readline() # first line is the copyright for the viewer itself +for line in copyrights: + pkg_info = pkg_line.match(line) + if pkg_info: + pkg = pkg_info.group(1) + if pkg not in copyright: + copyright[pkg] = pkg_info.group(2).strip() + else: + sys.exit("Duplicate copyright for %s" % pkg) + else: + sys.exit("Unrecognized --copyrights output: %s" % line) + +print viewer_copyright +for pkg in sorted(version): + print ': '.join([pkg, version[pkg]]) + if pkg in copyright: + print copyright[pkg] + else: + sys.exit("No copyright for %s" % pkg) -- cgit v1.2.3 From 20de60576f464aa87a38b5a270a5a72330452670 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 12 Dec 2014 14:33:20 -0500 Subject: Wrap call to autobuild in some diagnostic code. Hopefully this will make certain errors clearer, notably failure to launch autobuild due to "cannot find the file specified". --- scripts/packages-formatter.py | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/packages-formatter.py b/scripts/packages-formatter.py index 1432cdaebe..34fc92e44c 100755 --- a/scripts/packages-formatter.py +++ b/scripts/packages-formatter.py @@ -26,18 +26,41 @@ $/LicenseInfo$ """ import os import sys +import errno import re import subprocess -autobuild=os.getenv('AUTOBUILD', +_autobuild=os.getenv('AUTOBUILD', 'autobuild' if not ( sys.platform == 'win32' or sys.platform == 'cygwin') else 'autobuild.cmd') pkg_line=re.compile('^([\w-]+):\s+(.*)$') +def autobuild(*args): + """ + Launch autobuild with specified command-line arguments. + Return its stdout pipe from which the caller can read. + """ + # subprocess wants a list, not a tuple + command = [_autobuild] + list(args) + try: + child = subprocess.Popen(command, + stdin=None, stdout=subprocess.PIPE, + universal_newlines=True) + except OSError as err: + if err.errno != errno.ENOENT: + # Don't attempt to interpret anything but ENOENT + raise + # Here it's ENOENT: subprocess can't find the autobuild executable. + print >>sys.stderr, "packages-formatter on %s: can't run autobuild:\n%s\n%s" % \ + (sys.platform, ' '.join(command), err) + sys.exit(1) + + # no exceptions yet, let caller read stdout + return child.stdout + version={} -versions=subprocess.Popen([autobuild, 'install', '--versions'], - stdin=None, stdout=subprocess.PIPE, universal_newlines=True).stdout +versions=autobuild('install', '--versions') for line in versions: pkg_info = pkg_line.match(line) if pkg_info: @@ -50,8 +73,7 @@ for line in versions: sys.exit("Unrecognized --versions output: %s" % line) copyright={} -copyrights=subprocess.Popen([autobuild, 'install', '--copyrights'], - stdin=None, stdout=subprocess.PIPE, universal_newlines=True).stdout +copyrights=autobuild('install', '--copyrights') viewer_copyright = copyrights.readline() # first line is the copyright for the viewer itself for line in copyrights: pkg_info = pkg_line.match(line) -- cgit v1.2.3 From 9635923d5587588e9db71685234265e1f78856cf Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 22 Dec 2014 15:27:28 -0500 Subject: Temporarily work around cygwin /cygdrive/c pathname in AUTOBUILD. --- scripts/packages-formatter.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scripts') diff --git a/scripts/packages-formatter.py b/scripts/packages-formatter.py index 34fc92e44c..7e5e690e49 100755 --- a/scripts/packages-formatter.py +++ b/scripts/packages-formatter.py @@ -33,6 +33,8 @@ import subprocess _autobuild=os.getenv('AUTOBUILD', 'autobuild' if not ( sys.platform == 'win32' or sys.platform == 'cygwin') else 'autobuild.cmd') +# HACK: temporarily work around cygwin /cygdrive/c madness +_autobuild = re.sub(r"^/cygdrive/(.)/", r"\1:/", _autobuild) pkg_line=re.compile('^([\w-]+):\s+(.*)$') -- cgit v1.2.3 From 3d98ef6b08753d3e740ac9aa35e2364884f6c9cf Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 8 Jan 2015 16:44:27 -0500 Subject: Remove obsolete build script with ancient, erroneous hardcoded paths. --- scripts/automated_build_scripts/opensrc-build.sh | 391 ----------------------- 1 file changed, 391 deletions(-) delete mode 100755 scripts/automated_build_scripts/opensrc-build.sh (limited to 'scripts') diff --git a/scripts/automated_build_scripts/opensrc-build.sh b/scripts/automated_build_scripts/opensrc-build.sh deleted file mode 100755 index c1b592a972..0000000000 --- a/scripts/automated_build_scripts/opensrc-build.sh +++ /dev/null @@ -1,391 +0,0 @@ -#!/bin/sh - -# This is the build script used by Linden Lab's autmated build system. -# - -set -x - -export PATH=/bin:/usr/bin:$PATH -arch=`uname | cut -b-6` -here=`echo $0 | sed 's:[^/]*$:.:'` -year=`date +%Y` -branch=`svn info | grep '^URL:' | sed 's:.*/::'` -revision=`svn info | grep '^Revision:' | sed 's/.*: //'` - -[ x"$WGET_CACHE" = x ] && export WGET_CACHE=/var/tmp/parabuild/wget -[ x"$S3GET_URL" = x ] && export S3GET_URL=http://viewer-source-downloads.s3.amazonaws.com/$year -[ x"$S3PUT_URL" = x ] && export S3PUT_URL=https://s3.amazonaws.com/viewer-source-downloads/$year -[ x"$PUBLIC_URL" = x ] && export PUBLIC_URL=http://secondlife.com/developers/opensource/downloads/$year -[ x"$PUBLIC_EMAIL" = x ] && export PUBLIC_EMAIL=sldev-commits@lists.secondlife.com - -# Make sure command worked and bail out if not, reporting failure to parabuild -fail() -{ - release_lock - echo "BUILD FAILED" $@ - exit 1 -} - -pass() -{ - release_lock - echo "BUILD SUCCESSFUL" - exit 0 -} - -# Locking to avoid contention with u-s-c -LOCK_CREATE=/usr/bin/lockfile-create -LOCK_TOUCH=/usr/bin/lockfile-touch -LOCK_REMOVE=/usr/bin/lockfile-remove -LOCK_PROCESS= - -locking_available() -{ - test -x "$LOCK_CREATE"\ - -a -x "$LOCK_TOUCH"\ - -a -x "$LOCK_REMOVE" -} - -acquire_lock() -{ - if locking_available - then - if "$LOCK_CREATE" /var/lock/update-system-config --retry 99 - then - "$LOCK_TOUCH" /var/lock/update-system-config & - LOCK_PROCESS="$!" - else - fail acquire lock - fi - else - true - fi -} - -release_lock() -{ - if locking_available - then - if test x"$LOCK_PROCESS" != x - then - kill "$LOCK_PROCESS" - "$LOCK_REMOVE" /var/lock/update-system-config - else - echo No Lock Acquired >&2 - fi - else - true - fi -} - -get_asset() -{ - mkdir -p "$WGET_CACHE" || fail creating WGET_CACHE - local tarball=`basename "$1"` - test -r "$WGET_CACHE/$tarball" || ( cd "$WGET_CACHE" && curl --location --remote-name "$1" || fail getting $1 ) - case "$tarball" in - *.zip) unzip -qq -d .. -o "$WGET_CACHE/$tarball" || fail unzip $tarball ;; - *.tar.gz|*.tgz) tar -C .. -xzf "$WGET_CACHE/$tarball" || fail untar $tarball ;; - *) fail unrecognized filetype: $tarball ;; - esac -} - -s3_available() -{ - test -x "$helpers/s3get.sh" -a -x "$helpers/s3put.sh" -a -r "$helpers/s3curl.pl" -} - -build_dir_Darwin() -{ - echo build-darwin-universal -} - -build_dir_Linux() -{ - echo viewer-linux-i686-`echo $1 | tr A-Z a-z` -} - -build_dir_CYGWIN() -{ - echo build-vc80 -} - -installer_Darwin() -{ - ls -1td "`build_dir_Darwin Release`/newview/"*.dmg 2>/dev/null | sed 1q -} - -installer_Linux() -{ - ls -1td "`build_dir_Linux Release`/newview/"*.tar.bz2 2>/dev/null | sed 1q -} - -installer_CYGWIN() -{ - d=`build_dir_CYGWIN Release` - p=`sed 's:.*=::' "$d/newview/Release/touched.bat"` - echo "$d/newview/Release/$p" -} - -# deal with aborts etc.. -trap fail 1 2 3 14 15 - -# Check location -cd "$here/../.." - -test -x ../linden/scripts/automated_build_scripts/opensrc-build.sh\ - || fail 'The parent dir of your checkout needs to be named "linden"' - -. doc/asset_urls.txt -get_asset "$SLASSET_ART" - - -# Set up platform specific stuff -case "$arch" in - -# Note that we can only build the "Release" variant for Darwin, because of a compiler bug: -# ld: bl out of range (-16777272 max is +/-16M) -# from __static_initialization_and_destruction_0(int, int)at 0x033D319C -# in __StaticInit of -# indra/build-darwin-universal/newview/SecondLife.build/Debug/Second Life.build/Objects-normal/ppc/llvoicevisualizer.o -# to ___cxa_atexit$island_2 at 0x023D50F8 -# in __text of -# indra/build-darwin-universal/newview/SecondLife.build/Debug/Second Life.build/Objects-normal/ppc/Second Life -# in __static_initialization_and_destruction_0(int, int) -# from indra/build-darwin-universal/newview/SecondLife.build/Debug/Second Life.build/Objects-normal/ppc/llvoicevisualizer.o - -Darwin) - helpers=/usr/local/buildscripts/generic_vc - variants="Release" - cmake_generator="Xcode" - fmod=fmodapi375mac - fmod_tar="$fmod.zip" - fmod_so=libfmod.a - fmod_lib=lib - target_dirs="libraries/universal-darwin/lib_debug - libraries/universal-darwin/lib_release - libraries/universal-darwin/lib_release_client" - other_archs="$S3GET_URL/$branch/$revision/CYGWIN $S3GET_URL/$branch/$revision/Linux" - mail="$helpers"/mail.py - all_done="$helpers"/all_done.py - get_asset "$SLASSET_LIBS_DARWIN" - ;; - -CYGWIN) - helpers=/cygdrive/c/buildscripts - variants="Debug RelWithDebInfo Release" - #variants="Release" - cmake_generator="vc80" - fmod=fmodapi375win - fmod_tar=fmodapi375win.zip - fmod_so=fmodvc.lib - fmod_lib=lib - target_dirs="libraries/i686-win32/lib/debug - libraries/i686-win32/lib/release" - other_archs="$S3GET_URL/$branch/$revision/Darwin $S3GET_URL/$branch/$revision/Linux" - export PATH="/cygdrive/c/Python25:/cygdrive/c/Program Files/Cmake 2.6/bin":$PATH - export PERL="/cygdrive/c/Perl/bin/perl.exe" - export S3CURL="C:\\buildscripts\s3curl.pl" - export CURL="C:\\cygwin\\bin\\curl.exe" - mail="C:\\buildscripts\\mail.py" - all_done="C:\\buildscripts\\all_done.py" - get_asset "$SLASSET_LIBS_WIN32" - ;; - -Linux) - helpers=/var/opt/parabuild/buildscripts/generic_vc - [ x"$CXX" = x ] && test -x /usr/bin/g++-4.1 && export CXX=/usr/bin/g++-4.1 - acquire_lock - variants="Debug RelWithDebInfo Release" - #variants="Release" - cmake_generator="Unix Makefiles" - fmod=fmodapi375linux - fmod_tar="$fmod".tar.gz - fmod_so=libfmod-3.75.so - fmod_lib=. - target_dirs="libraries/i686-linux/lib_debug - libraries/i686-linux/lib_release - libraries/i686-linux/lib_release_client" - other_archs="$S3GET_URL/$branch/$revision/Darwin $S3GET_URL/$branch/$revision/CYGWIN" - mail="$helpers"/mail.py - all_done="$helpers"/all_done.py - # Change the DISTCC_DIR to be somewhere that the parabuild process can write to - if test -r /etc/debian_version - then - [ x"$DISTCC_DIR" = x ] && export DISTCC_DIR=/var/tmp/parabuild - case `cat /etc/debian_version` in - 3.*) [ x"$DISTCC_HOSTS" = x ]\ - && export DISTCC_HOSTS="build-linux-1 - build-linux-2 - build-linux-3 - build-linux-4 - build-linux-5" ;; - 4.*) [ x"$DISTCC_HOSTS" = x ]\ - && export DISTCC_HOSTS="build-linux-6 - build-linux-7 - build-linux-8 - build-linux-9" ;; - esac - fi - - get_asset "$SLASSET_LIBS_LINUXI386" - ;; - -*) fail undefined $arch ;; -esac - -get_asset "http://www.fmod.org/index.php/release/version/$fmod_tar" - -# Special case for Mac... -case "$arch" in - -Darwin) - if lipo -create -output "../$fmod"/api/$fmod_lib/libfmod-universal.a\ - "../$fmod"/api/$fmod_lib/libfmod.a\ - "../$fmod"/api/$fmod_lib/libfmodx86.a - then - mv "../$fmod"/api/$fmod_lib/libfmod.a "../$fmod"/api/$fmod_lib/libfmodppc.a - mv "../$fmod"/api/$fmod_lib/libfmod-universal.a "../$fmod"/api/$fmod_lib/libfmod.a - echo Created fat binary - else - fail running lipo - fi - ;; - -esac - -# ensure helpers are up to date -( cd "$helpers" && svn up ) - -# First, go into the directory where the code was checked out by Parabuild -cd indra - -# This is the way it works now, but it will soon work on a variant dependent way -for target_dir in $target_dirs -do - mkdir -p "../$target_dir" - cp -f "../../$fmod/api/$fmod_lib/$fmod_so" "../$target_dir" -done -mkdir -p "../libraries/include" -cp -f "../../$fmod/api/inc/"* "../libraries/include" - -# Special Windows case -test -r "../../$fmod/api/fmod.dll" && cp -f "../../$fmod/api/fmod.dll" newview - -# Now run the build command over all variants -succeeded=true -cp /dev/null build.log - -### TEST CODE - remove when done -### variants= -### echo "Artificial build failure to test notifications" > build.log -### succeeded=false -### END TEST CODE - -for variant in $variants -do - build_dir=`build_dir_$arch $variant` - rm -rf "$build_dir" - # This is the way it will work in future - #for target_dir in $target_dirs - #do - # mkdir -p "$build_dir/$target_dir" - # cp "../../$fmod/api/$fmod_lib/$fmod_so" "$build_dir/$target_dir" - #done - #mkdir -p "$build_dir/libraries/include" - #cp "../../$fmod/api/inc/"* "$build_dir/libraries/include" - echo "==== $variant ====" >> build.log - if ./develop.py \ - --unattended \ - --incredibuild \ - -t $variant \ - -G "$cmake_generator" \ - configure \ - -DPACKAGE:BOOL=ON >>build.log 2>&1 - then - if ./develop.py\ - --unattended\ - --incredibuild \ - -t $variant\ - -G "$cmake_generator" \ - build package >>build.log 2>&1 - then - # run tests if needed - true - else - succeeded=false - fi - else - succeeded=false - fi -done - -# check statuis and upload results to S3 -subject= -if $succeeded -then - package=`installer_$arch` - test -r "$package" || fail not found: $package - package_file=`echo $package | sed 's:.*/::'` - if s3_available - then - echo "$PUBLIC_URL/$branch/$revision/$package_file" > "$arch" - echo "$PUBLIC_URL/$branch/$revision/good-build.$arch" >> "$arch" - "$helpers/s3put.sh" "$package" "$S3PUT_URL/$branch/$revision/$package_file" binary/octet-stream\ - || fail Uploading "$package" - "$helpers/s3put.sh" build.log "$S3PUT_URL/$branch/$revision/good-build.$arch" text/plain\ - || fail Uploading build.log - "$helpers/s3put.sh" "$arch" "$S3PUT_URL/$branch/$revision/$arch" text/plain\ - || fail Uploading token file - if python "$all_done"\ - curl\ - "$S3GET_URL/$branch/$revision/$arch"\ - $other_archs > message - then - subject="Successful Build for $branch ($revision)" - fi - else - true s3 is not available - fi -else - if s3_available - then - "$helpers/s3put.sh" build.log "$S3PUT_URL/$branch/$revision/failed-build.$arch" text/plain\ - || fail Uploading build.log - subject="Failed Build for $branch ($revision) on $arch" - cat >message <> message - elif [ x"$PARABUILD_PREVIOUS_CHANGE_LIST_NUMBER" = x ] - then - ( cd .. && svn log --verbose --stop-on-copy --limit 50 ) >>message - else - ( cd .. && svn log --verbose -r"$PARABUILD_PREVIOUS_CHANGE_LIST_NUMBER":"$PARABUILD_CHANGE_LIST_NUMBER" ) >>message - fi - # $PUBLIC_EMAIL can be a list, so no quotes - python "$mail" "$subject" $PUBLIC_EMAIL Date: Thu, 8 Jan 2015 16:48:29 -0500 Subject: Rationalize use of AUTOBUILD environment variable across languages. Ensure that AUTOBUILD is always in native path syntax on every platform. Remove local build.sh logic to infer AUTOBUILD: either the generic build.sh has set it properly, or scream for help. Since cygwin bash scripts need a cygwin-syntax path to autobuild, convert to a local 'autobuild' variable using shell_path. Remove kludges in other languages involving cygdrive twiddling. --- scripts/packages-formatter.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/packages-formatter.py b/scripts/packages-formatter.py index 7e5e690e49..4e66cf9ed4 100755 --- a/scripts/packages-formatter.py +++ b/scripts/packages-formatter.py @@ -30,11 +30,7 @@ import errno import re import subprocess -_autobuild=os.getenv('AUTOBUILD', - 'autobuild' if not ( sys.platform == 'win32' or sys.platform == 'cygwin') - else 'autobuild.cmd') -# HACK: temporarily work around cygwin /cygdrive/c madness -_autobuild = re.sub(r"^/cygdrive/(.)/", r"\1:/", _autobuild) +_autobuild=os.getenv('AUTOBUILD', 'autobuild') pkg_line=re.compile('^([\w-]+):\s+(.*)$') -- cgit v1.2.3 From 136a925536dc55749de665424469d2111b14ba63 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Thu, 2 Apr 2015 16:01:17 -0400 Subject: add script to check xml files written by the viewer --- scripts/check-viewer-xml | 102 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100755 scripts/check-viewer-xml (limited to 'scripts') diff --git a/scripts/check-viewer-xml b/scripts/check-viewer-xml new file mode 100755 index 0000000000..27c1112492 --- /dev/null +++ b/scripts/check-viewer-xml @@ -0,0 +1,102 @@ +#!/usr/bin/env python +from __future__ import print_function +import sys +import os +import argparse +import xml.etree.ElementTree as xml + +try: + from llbase import llsd +except ImportError: + try: + from indra.base import llsd + except ImportError: + sys.exit("""Failed to import python llsd module from llbase or indra.base. +Try + pip install llbase +or + sudo pip install llbase +""") + +def warning(*objs): + print(*objs, file=sys.stderr) + +def xml_is_ok(file): + # Check that the XML file is well formed. + try : + elements = xml.parse(file) + except IOError as read_error: + warning("XML not readable '%s':\n %s" % (file, read_error)) + return False + except xml.ParseError as parse_error : + warning("XML not well-formed '%s':\n %s" % (file, parse_error.msg)) + return False + + root = elements.getroot() + if root.tag == 'llsd': + # if it's LLSD, we should be able to also validate that + with open(file, "r") as llsd_file: + llsd_content=llsd_file.read() + try: + llsd.parse(llsd_content) + except Exception as validity_error: + warning("LLSD not valid '%s':\n %s" % (file, validity_error)) + return False + elif arg.verbosity == 'verbose': + warning(" %s is not a document type that can be validated" % root.tag) + + return True + +cmd_line = argparse.ArgumentParser(description='Checks all xml files found in viewer settings and cache directories ', + prog='check-viewer-xml', + ) +cmd_line.add_argument('directory', nargs='*', default=None, + help='additional directories to check') +verbosity_options=cmd_line.add_mutually_exclusive_group() +verbosity_options.add_argument('-v', '--verbose', + help='verbose output', action='store_const', const='verbose', dest='verbosity') +verbosity_options.add_argument('-q', '--quiet', + help='output errors only', action='store_const', const='quiet', dest='verbosity', default='normal') + +arg = cmd_line.parse_args() + +if sys.platform == 'darwin': + CheckDirs = [ os.path.expanduser('~/Library/Caches/SecondLife'), + os.path.expanduser('~/Library/Application Support/SecondLife'), + ] +elif sys.platform == 'linux2': + CheckDirs = [ os.path.expanduser('~/.secondlife'), + ] +elif sys.platform == 'win32' or sys.platform == 'cygwin': + CheckDirs = [ os.path.expanduser('~\\Local Settings\\Temp'), + os.path.expanduser('~\\Application\\Data\\Secondlife'), + os.path.expanduser('~\\AppData\\Roaming\\Secondlife'), + os.path.expanduser('~\\AppData\\Local\\Secondlife'), + ] +else: + sys.exit("unrecognized platform '%s'" % sys.platform) + +if arg.directory: + CheckDirs.extend(arg.directory) + +checked_files = 0 +invalid_files = 0 +for root in filter(os.path.isdir, CheckDirs): + if arg.verbosity == 'verbose': + print("Searching '%s'" % root) + for directory, dirs, files in os.walk(root): + for file in files: + if file.endswith('.xml'): + xml_file = os.path.join(directory,file) + if arg.verbosity == 'verbose': + print("Checking '%s'" % xml_file) + checked_files += 1 + if not xml_is_ok(xml_file): + invalid_files += 1 + +if arg.verbosity != 'quiet': + print("Checked %d files, %d errors found." % (checked_files, invalid_files)) + +sys.exit(invalid_files) + + -- cgit v1.2.3 From 6b9b4c91d122dccabf7541af70ed68a623ad8810 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Thu, 9 Apr 2015 11:12:47 -0400 Subject: Detect running under cygwin and fail gracefully --- scripts/check-viewer-xml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/check-viewer-xml b/scripts/check-viewer-xml index 27c1112492..85366c02ae 100755 --- a/scripts/check-viewer-xml +++ b/scripts/check-viewer-xml @@ -68,11 +68,13 @@ elif sys.platform == 'linux2': CheckDirs = [ os.path.expanduser('~/.secondlife'), ] elif sys.platform == 'win32' or sys.platform == 'cygwin': - CheckDirs = [ os.path.expanduser('~\\Local Settings\\Temp'), - os.path.expanduser('~\\Application\\Data\\Secondlife'), - os.path.expanduser('~\\AppData\\Roaming\\Secondlife'), - os.path.expanduser('~\\AppData\\Local\\Secondlife'), - ] + if os.path.isdir(os.path.expanduser('~\\AppData\\Roaming')): + CheckDirs = [ os.path.expanduser('~\\Application\\Data\\Secondlife'), + os.path.expanduser('~\\AppData\\Roaming\\Secondlife'), + os.path.expanduser('~\\AppData\\Local\\Secondlife'), + ] + else: + sys.exit("No AppData\\Roaming directory found;\nThis script must be run in a native Windows command shell.\nRunning under cygwin does not work.") else: sys.exit("unrecognized platform '%s'" % sys.platform) -- cgit v1.2.3 From a49e11efd9e249cc6d3cf5bcffaafe1e831f2fa9 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Tue, 14 Apr 2015 10:44:16 -0400 Subject: remove check-viewer-xml (moved to the viewer-test-tools repo) --- scripts/check-viewer-xml | 104 ----------------------------------------------- 1 file changed, 104 deletions(-) delete mode 100755 scripts/check-viewer-xml (limited to 'scripts') diff --git a/scripts/check-viewer-xml b/scripts/check-viewer-xml deleted file mode 100755 index 85366c02ae..0000000000 --- a/scripts/check-viewer-xml +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/env python -from __future__ import print_function -import sys -import os -import argparse -import xml.etree.ElementTree as xml - -try: - from llbase import llsd -except ImportError: - try: - from indra.base import llsd - except ImportError: - sys.exit("""Failed to import python llsd module from llbase or indra.base. -Try - pip install llbase -or - sudo pip install llbase -""") - -def warning(*objs): - print(*objs, file=sys.stderr) - -def xml_is_ok(file): - # Check that the XML file is well formed. - try : - elements = xml.parse(file) - except IOError as read_error: - warning("XML not readable '%s':\n %s" % (file, read_error)) - return False - except xml.ParseError as parse_error : - warning("XML not well-formed '%s':\n %s" % (file, parse_error.msg)) - return False - - root = elements.getroot() - if root.tag == 'llsd': - # if it's LLSD, we should be able to also validate that - with open(file, "r") as llsd_file: - llsd_content=llsd_file.read() - try: - llsd.parse(llsd_content) - except Exception as validity_error: - warning("LLSD not valid '%s':\n %s" % (file, validity_error)) - return False - elif arg.verbosity == 'verbose': - warning(" %s is not a document type that can be validated" % root.tag) - - return True - -cmd_line = argparse.ArgumentParser(description='Checks all xml files found in viewer settings and cache directories ', - prog='check-viewer-xml', - ) -cmd_line.add_argument('directory', nargs='*', default=None, - help='additional directories to check') -verbosity_options=cmd_line.add_mutually_exclusive_group() -verbosity_options.add_argument('-v', '--verbose', - help='verbose output', action='store_const', const='verbose', dest='verbosity') -verbosity_options.add_argument('-q', '--quiet', - help='output errors only', action='store_const', const='quiet', dest='verbosity', default='normal') - -arg = cmd_line.parse_args() - -if sys.platform == 'darwin': - CheckDirs = [ os.path.expanduser('~/Library/Caches/SecondLife'), - os.path.expanduser('~/Library/Application Support/SecondLife'), - ] -elif sys.platform == 'linux2': - CheckDirs = [ os.path.expanduser('~/.secondlife'), - ] -elif sys.platform == 'win32' or sys.platform == 'cygwin': - if os.path.isdir(os.path.expanduser('~\\AppData\\Roaming')): - CheckDirs = [ os.path.expanduser('~\\Application\\Data\\Secondlife'), - os.path.expanduser('~\\AppData\\Roaming\\Secondlife'), - os.path.expanduser('~\\AppData\\Local\\Secondlife'), - ] - else: - sys.exit("No AppData\\Roaming directory found;\nThis script must be run in a native Windows command shell.\nRunning under cygwin does not work.") -else: - sys.exit("unrecognized platform '%s'" % sys.platform) - -if arg.directory: - CheckDirs.extend(arg.directory) - -checked_files = 0 -invalid_files = 0 -for root in filter(os.path.isdir, CheckDirs): - if arg.verbosity == 'verbose': - print("Searching '%s'" % root) - for directory, dirs, files in os.walk(root): - for file in files: - if file.endswith('.xml'): - xml_file = os.path.join(directory,file) - if arg.verbosity == 'verbose': - print("Checking '%s'" % xml_file) - checked_files += 1 - if not xml_is_ok(xml_file): - invalid_files += 1 - -if arg.verbosity != 'quiet': - print("Checked %d files, %d errors found." % (checked_files, invalid_files)) - -sys.exit(invalid_files) - - -- cgit v1.2.3