From: zooko Date: Sun, 16 May 2010 03:01:22 +0000 (+0530) Subject: setup: new improved show-tool-versions.sh X-Git-Url: https://git.rkrishnan.org/(%5B%5E?a=commitdiff_plain;h=344ede13bb4473efed7b76e64677bd726de778ff;p=tahoe-lafs%2Fzfec.git setup: new improved show-tool-versions.sh Ignore-this: 1f0f7f0979a64dc0998a300a04a2f0 darcs-hash:0ad2363cddb1df20fac07795320c2b88f45ea5c3 --- diff --git a/misc/show-tool-versions.py b/misc/show-tool-versions.py index ffe9aa0..df586c4 100755 --- a/misc/show-tool-versions.py +++ b/misc/show-tool-versions.py @@ -2,82 +2,82 @@ import os, subprocess, sys -try: - import platform - out = platform.platform() - print - print "platform:", out.replace("\n", " ") -except EnvironmentError, le: - sys.stderr.write("Got exception using 'platform': %s" % (le,)) - pass +def print_platform(): + try: + import platform + out = platform.platform() + print + print "platform:", out.replace("\n", " ") + except EnvironmentError, le: + sys.stderr.write("Got exception using 'platform': %s\n" % (le,)) + pass -print "python:", sys.version.replace("\n", " ") + ', maxunicode: ' + str(sys.maxunicode) +def print_python_ver(): + print "python:", sys.version.replace("\n", " ") + ', maxunicode: ' + str(sys.maxunicode) -try: - import pkg_resources - out = str(pkg_resources.require("setuptools")) - print - print "setuptools:", out.replace("\n", " ") -except (ImportError, EnvironmentError), le: - sys.stderr.write("Got exception using 'pkg_resources' to get the version of setuptools: %s" % (le,)) - pass +def print_cmd_ver(cmdlist, label=None): + try: + res = subprocess.Popen(cmdlist, stdin=open(os.devnull), + stdout=subprocess.PIPE).communicate()[0] + if label is None: + label = cmdlist[0] + print + print label + ': ' + res.replace("\n", " ") + except EnvironmentError, le: + sys.stderr.write("Got exception invoking '%s': %s\n" % (cmdlist[0], le,)) + pass -try: - out = subprocess.Popen(["buildbot", "--version"], - stdout=subprocess.PIPE).communicate()[0] - print "buildbot:", out.replace("\n", " ") -except EnvironmentError, le: - sys.stderr.write("Got exception invoking 'buildbot': %s" % (le,)) - pass +def print_as_ver(): + if os.path.exists('a.out'): + print + print "WARNING: a file named a.out exists, and getting the version of the 'as' assembler writes to that filename, so I'm not attempting to get the version of 'as'." + return + try: + res = subprocess.Popen(['as', '-version'], stdin=open(os.devnull), + stderr=subprocess.PIPE).communicate()[1] + print + print 'as: ' + res.replace("\n", " ") + os.remove('a.out') + except EnvironmentError, le: + sys.stderr.write("Got exception invoking '%s': %s\n" % ('as', le,)) + pass -try: - out = subprocess.Popen(["cl"], - stdout=subprocess.PIPE).communicate()[0] - print "cl:", out.replace("\n", " ") -except EnvironmentError, le: - sys.stderr.write("Got exception invoking 'cl': %s" % (le,)) - pass +def print_setuptools_ver(): + try: + import pkg_resources + out = str(pkg_resources.require("setuptools")) + print + print "setuptools:", out.replace("\n", " ") + except (ImportError, EnvironmentError), le: + sys.stderr.write("Got exception using 'pkg_resources' to get the version of setuptools: %s\n" % (le,)) + pass -try: - out = subprocess.Popen(["gcc", "--version"], - stdout=subprocess.PIPE).communicate()[0] - print "gcc:", out.replace("\n", " ") -except EnvironmentError, le: - sys.stderr.write("Got exception invoking 'gcc': %s" % (le,)) - pass +def print_py_pkg_ver(pkgname): + try: + import pkg_resources + out = str(pkg_resources.require(pkgname)) + print + print pkgname + ': ' + out.replace("\n", " ") + except (ImportError, EnvironmentError), le: + sys.stderr.write("Got exception using 'pkg_resources' to get the version of %s: %s\n" % (pkgname, le,)) + pass + except pkg_resources.DistributionNotFound, le: + sys.stderr.write("pkg_resources reported no %s package installed: %s\n" % (pkgname, le,)) + pass -try: - out = subprocess.Popen(["darcs", "--version"], - stdout=subprocess.PIPE).communicate()[0] - full = subprocess.Popen(["darcs", "--exact-version"], - stdout=subprocess.PIPE).communicate()[0] - print - print "darcs:", out.replace("\n", " ") - print full.rstrip() -except EnvironmentError, le: - sys.stderr.write("Got exception invoking 'darcs': %s" % (le,)) - pass +print_platform() -try: - import pkg_resources - out = str(pkg_resources.require("coverage")) - print - print "coverage:", out.replace("\n", " ") -except (ImportError, EnvironmentError), le: - sys.stderr.write("Got exception using 'pkg_resources' to get the version of coverage: %s" % (le,)) - pass -except pkg_resources.DistributionNotFound, le: - sys.stderr.write("pkg_resources reported no coverage package installed: %s" % (le,)) - pass +print_python_ver() -try: - import pkg_resources - out = str(pkg_resources.require("trialcoverage")) - print - print "trialcoverage:", out.replace("\n", " ") -except (ImportError, EnvironmentError), le: - sys.stderr.write("Got exception using 'pkg_resources' to get the version of trialcoverage: %s" % (le,)) - pass -except pkg_resources.DistributionNotFound, le: - sys.stderr.write("pkg_resources reported no trialcoverage package installed: %s" % (le,)) - pass +print_cmd_ver(['buildbot', '--version']) +print_cmd_ver(['cl']) +print_cmd_ver(['gcc', '--version']) +print_cmd_ver(['darcs', '--version']) +print_cmd_ver(['darcs', '--exact-version'], label='darcs-exact-version') +print_cmd_ver(['7za']) + +print_setuptools_ver() + +print_py_pkg_ver('coverage') +print_py_pkg_ver('trialcoverage') +print_py_pkg_ver('setuptools_trial')