From: zooko Date: Mon, 13 Feb 2012 13:33:02 +0000 (+0530) Subject: setup: copy in the latest version of show-tool-versions from the pycryptopp project... X-Git-Url: https://git.rkrishnan.org/?a=commitdiff_plain;h=2b50af608e06371af87bb436c3ddf3e6d9a7c315;p=tahoe-lafs%2Fzfec.git setup: copy in the latest version of show-tool-versions from the pycryptopp project (plus tweaks to query tools relevant to zfec instead of relevant to pycryptopp) Ignore-this: a4044529b66fb204dcbdf8d0c826fb21 darcs-hash:f6c5ad5649aa3f33ba7934051e127209428c544f --- diff --git a/misc/build_helpers/show-tool-versions.py b/misc/build_helpers/show-tool-versions.py index 3c1a196..9976ecf 100755 --- a/misc/build_helpers/show-tool-versions.py +++ b/misc/build_helpers/show-tool-versions.py @@ -1,17 +1,22 @@ #! /usr/bin/env python -import os, subprocess, sys, traceback +import errno, locale, os, platform, subprocess, sys, traceback -def foldlines(s): - return s.replace("\n", " ").replace("\r", "") +def foldlines(s, numlines=None): + lines = s.split("\n") + if numlines is not None: + lines = lines[:numlines] + return " ".join(lines).replace("\r", "") def print_platform(): - print try: import platform out = platform.platform() print - print "platform:", out.replace("\n", " ") + print "platform:", foldlines(out) + print "machine: ", platform.machine() + if hasattr(platform, 'linux_distribution'): + print "linux_distribution:", repr(platform.linux_distribution()) except EnvironmentError: sys.stderr.write("Got exception using 'platform'. Exception follows\n") traceback.print_exc(file=sys.stderr) @@ -19,26 +24,52 @@ def print_platform(): pass def print_python_ver(): - print print "python:", foldlines(sys.version) print 'maxunicode: ' + str(sys.maxunicode) -def print_stdout(cmdlist, label=None): - print +def print_python_encoding_settings(): + print 'filesystem.encoding: ' + str(sys.getfilesystemencoding()) + print 'locale.getpreferredencoding: ' + str(locale.getpreferredencoding()) + try: + print 'locale.defaultlocale: ' + str(locale.getdefaultlocale()) + except ValueError, e: + print 'got exception from locale.getdefaultlocale(): ', e + print 'locale.locale: ' + str(locale.getlocale()) + +def print_stdout(cmdlist, label=None, numlines=None): + if label is None: + label = cmdlist[0] try: res = subprocess.Popen(cmdlist, stdin=open(os.devnull), stdout=subprocess.PIPE).communicate()[0] - if label is None: - label = cmdlist[0] + print label + ': ' + foldlines(res, numlines) + except EnvironmentError, e: + if isinstance(e, OSError) and e.errno == errno.ENOENT: + print str(label) + ': ' + str(cmdlist[0]) + ': no such file or directory' + return + sys.stderr.write("\n%s: Got exception invoking '%s'. Exception follows.\n" % (label, cmdlist[0],)) + traceback.print_exc(file=sys.stderr) + sys.stderr.flush() + pass + +def print_stderr(cmdlist, label=None): + if label is None: + label = cmdlist[0] + try: + res = subprocess.Popen(cmdlist, stdin=open(os.devnull), + stderr=subprocess.PIPE).communicate()[1] print label + ': ' + foldlines(res) - except EnvironmentError: - sys.stderr.write("\nGot exception invoking '%s'. Exception follows.\n" % (cmdlist[0],)) + except EnvironmentError, e: + if isinstance(e, OSError) and e.errno == errno.ENOENT: + print str(label) + ': ' + str(cmdlist[0]) + ': no such file or directory' + return + sys.stderr.write("\n%s: Got exception invoking '%s'. Exception follows.\n" % (label, cmdlist[0],)) traceback.print_exc(file=sys.stderr) sys.stderr.flush() pass + def print_as_ver(): - print if os.path.exists('a.out'): 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 @@ -55,7 +86,6 @@ def print_as_ver(): pass def print_setuptools_ver(): - print try: import pkg_resources out = str(pkg_resources.require("setuptools")) @@ -65,11 +95,13 @@ def print_setuptools_ver(): traceback.print_exc(file=sys.stderr) sys.stderr.flush() pass + except pkg_resources.DistributionNotFound: + print 'setuptools: DistributionNotFound' + pass def print_py_pkg_ver(pkgname, modulename=None): if modulename is None: modulename = pkgname - print try: import pkg_resources @@ -81,9 +113,7 @@ def print_py_pkg_ver(pkgname, modulename=None): sys.stderr.flush() pass except pkg_resources.DistributionNotFound: - sys.stderr.write("\npkg_resources reported no %s package installed. Exception follows.\n" % (pkgname,)) - traceback.print_exc(file=sys.stderr) - sys.stderr.flush() + print pkgname + ': DistributionNotFound' pass try: __import__(modulename) @@ -98,24 +128,27 @@ def print_py_pkg_ver(pkgname, modulename=None): pass print_platform() - +print print_python_ver() - +print +print_stdout(['locale']) +print_python_encoding_settings() +print print_stdout(['buildbot', '--version']) -print_stdout(['cl']) -print_stdout(['gcc', '--version']) +print_stdout(['buildslave', '--version']) +if 'windows' in platform.system().lower(): + print_stderr(['cl']) +print_stdout(['cc', '--version'], numlines=1) +print_stdout(['gcc', '--version'], numlines=1) +print_stdout(['git', '--version']) print_stdout(['darcs', '--version']) print_stdout(['darcs', '--exact-version'], label='darcs-exact-version') -print_stdout(['7za']) print_stdout(['flappclient', '--version']) print_stdout(['valgrind', '--version']) print_setuptools_ver() print_py_pkg_ver('coverage') -print_py_pkg_ver('trialcoverage') -print_py_pkg_ver('setuptools_trial') -print_py_pkg_ver('setuptools_darcs') -print_py_pkg_ver('darcsver') +print_py_pkg_ver('pyflakes') print_py_pkg_ver('Twisted', 'twisted') print_py_pkg_ver('TwistedCore', 'twisted.python')