mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-23 23:02:25 +00:00
misc/build_helpers/show-tool-versions.py: get sys.std{out,err}.encoding and 'as' version correctly, and improve formatting.
This commit is contained in:
parent
cd7fb133b7
commit
66a0604c71
@ -2,12 +2,15 @@
|
|||||||
|
|
||||||
import locale, os, subprocess, sys
|
import locale, os, subprocess, sys
|
||||||
|
|
||||||
|
def foldlines(s):
|
||||||
|
return s.replace("\n", " ").replace("\r", "")
|
||||||
|
|
||||||
def print_platform():
|
def print_platform():
|
||||||
|
print
|
||||||
try:
|
try:
|
||||||
import platform
|
import platform
|
||||||
out = platform.platform()
|
out = platform.platform()
|
||||||
print
|
print "platform:", foldlines(out)
|
||||||
print "platform:", out.replace("\n", " ")
|
|
||||||
if hasattr(platform, 'linux_distribution'):
|
if hasattr(platform, 'linux_distribution'):
|
||||||
print "linux_distribution:", repr(platform.linux_distribution())
|
print "linux_distribution:", repr(platform.linux_distribution())
|
||||||
except EnvironmentError, le:
|
except EnvironmentError, le:
|
||||||
@ -16,52 +19,52 @@ def print_platform():
|
|||||||
|
|
||||||
def print_python_ver():
|
def print_python_ver():
|
||||||
print
|
print
|
||||||
print "python:", sys.version.replace("\n", " "),
|
print "python:", foldlines(sys.version)
|
||||||
print ', maxunicode: ' + str(sys.maxunicode),
|
print 'maxunicode: ' + str(sys.maxunicode)
|
||||||
|
|
||||||
def print_locale():
|
|
||||||
cmdlist = ['locale']
|
|
||||||
try:
|
|
||||||
res = subprocess.Popen(cmdlist, stdin=open(os.devnull),
|
|
||||||
stdout=subprocess.PIPE).communicate()[0]
|
|
||||||
print
|
|
||||||
print "locale: ", res.replace("\n", " ")
|
|
||||||
except EnvironmentError, le:
|
|
||||||
sys.stderr.write("Got exception invoking '%s': %s\n" % (cmdlist[0], le,))
|
|
||||||
pass
|
|
||||||
|
|
||||||
def print_python_encoding_settings():
|
def print_python_encoding_settings():
|
||||||
|
print_stderr([sys.executable, '-c', 'import sys; print >>sys.stderr, sys.stdout.encoding'], label='sys.stdout.encoding')
|
||||||
|
print_stdout([sys.executable, '-c', 'import sys; print sys.stderr.encoding'], label='sys.stderr.encoding')
|
||||||
print
|
print
|
||||||
print 'stdout.encoding: ' + str(sys.stdout.encoding),
|
print 'filesystem.encoding: ' + str(sys.getfilesystemencoding())
|
||||||
print ', stdin.encoding: ' + str(sys.stdin.encoding),
|
print 'locale.getpreferredencoding: ' + str(locale.getpreferredencoding())
|
||||||
print ', filesystem.encoding: ' + str(sys.getfilesystemencoding()),
|
print 'os.path.supports_unicode_filenames: ' + str(os.path.supports_unicode_filenames)
|
||||||
print ', locale.getpreferredencoding: ' + str(locale.getpreferredencoding()),
|
print 'locale.defaultlocale: ' + str(locale.getdefaultlocale())
|
||||||
print ', os.path.supports_unicode_filenames: ' + str(os.path.supports_unicode_filenames),
|
print 'locale.locale: ' + str(locale.getlocale())
|
||||||
print ', locale.defaultlocale: ' + str(locale.getdefaultlocale()),
|
|
||||||
print ', locale.locale: ' + str(locale.getlocale())
|
|
||||||
|
|
||||||
def print_cmd_ver(cmdlist, label=None):
|
def print_stdout(cmdlist, label=None):
|
||||||
|
print
|
||||||
try:
|
try:
|
||||||
res = subprocess.Popen(cmdlist, stdin=open(os.devnull),
|
res = subprocess.Popen(cmdlist, stdin=open(os.devnull),
|
||||||
stdout=subprocess.PIPE).communicate()[0]
|
stdout=subprocess.PIPE).communicate()[0]
|
||||||
if label is None:
|
if label is None:
|
||||||
label = cmdlist[0]
|
label = cmdlist[0]
|
||||||
print
|
print label + ': ' + foldlines(res)
|
||||||
print label + ': ' + res.replace("\n", " ")
|
except EnvironmentError, le:
|
||||||
|
sys.stderr.write("Got exception invoking '%s': %s\n" % (cmdlist[0], le,))
|
||||||
|
pass
|
||||||
|
|
||||||
|
def print_stderr(cmdlist, label=None):
|
||||||
|
print
|
||||||
|
try:
|
||||||
|
res = subprocess.Popen(cmdlist, stdin=open(os.devnull),
|
||||||
|
stderr=subprocess.PIPE).communicate()[1]
|
||||||
|
if label is None:
|
||||||
|
label = cmdlist[0]
|
||||||
|
print label + ': ' + foldlines(res)
|
||||||
except EnvironmentError, le:
|
except EnvironmentError, le:
|
||||||
sys.stderr.write("Got exception invoking '%s': %s\n" % (cmdlist[0], le,))
|
sys.stderr.write("Got exception invoking '%s': %s\n" % (cmdlist[0], le,))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def print_as_ver():
|
def print_as_ver():
|
||||||
|
print
|
||||||
if os.path.exists('a.out'):
|
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'."
|
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
|
return
|
||||||
try:
|
try:
|
||||||
res = subprocess.Popen(['as', '-version'], stdin=open(os.devnull),
|
res = subprocess.Popen(['as', '-version'], stdin=open(os.devnull),
|
||||||
stderr=subprocess.PIPE).communicate()[1]
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
|
||||||
print
|
print 'as: ' + foldlines(res[0]+' '+res[1])
|
||||||
print 'as: ' + res.replace("\n", " ")
|
|
||||||
if os.path.exists('a.out'):
|
if os.path.exists('a.out'):
|
||||||
os.remove('a.out')
|
os.remove('a.out')
|
||||||
except EnvironmentError, le:
|
except EnvironmentError, le:
|
||||||
@ -69,21 +72,21 @@ def print_as_ver():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def print_setuptools_ver():
|
def print_setuptools_ver():
|
||||||
|
print
|
||||||
try:
|
try:
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
out = str(pkg_resources.require("setuptools"))
|
out = str(pkg_resources.require("setuptools"))
|
||||||
print
|
print "setuptools:", foldlines(out)
|
||||||
print "setuptools:", out.replace("\n", " ")
|
|
||||||
except (ImportError, EnvironmentError), le:
|
except (ImportError, EnvironmentError), le:
|
||||||
sys.stderr.write("Got exception using 'pkg_resources' to get the version of setuptools: %s\n" % (le,))
|
sys.stderr.write("Got exception using 'pkg_resources' to get the version of setuptools: %s\n" % (le,))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def print_py_pkg_ver(pkgname):
|
def print_py_pkg_ver(pkgname):
|
||||||
|
print
|
||||||
try:
|
try:
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
out = str(pkg_resources.require(pkgname))
|
out = str(pkg_resources.require(pkgname))
|
||||||
print
|
print pkgname + ': ' + foldlines(out)
|
||||||
print pkgname + ': ' + out.replace("\n", " ")
|
|
||||||
except (ImportError, EnvironmentError), le:
|
except (ImportError, EnvironmentError), le:
|
||||||
sys.stderr.write("Got exception using 'pkg_resources' to get the version of %s: %s\n" % (pkgname, le,))
|
sys.stderr.write("Got exception using 'pkg_resources' to get the version of %s: %s\n" % (pkgname, le,))
|
||||||
pass
|
pass
|
||||||
@ -95,17 +98,17 @@ print_platform()
|
|||||||
|
|
||||||
print_python_ver()
|
print_python_ver()
|
||||||
|
|
||||||
print_locale()
|
print_stdout(['locale'])
|
||||||
print_python_encoding_settings()
|
print_python_encoding_settings()
|
||||||
|
|
||||||
print_cmd_ver(['buildbot', '--version'])
|
print_stdout(['buildbot', '--version'])
|
||||||
print_cmd_ver(['cl'])
|
print_stdout(['cl'])
|
||||||
print_cmd_ver(['gcc', '--version'])
|
print_stdout(['gcc', '--version'])
|
||||||
print_cmd_ver(['g++', '--version'])
|
print_stdout(['g++', '--version'])
|
||||||
print_cmd_ver(['cryptest', 'V'])
|
print_stdout(['cryptest', 'V'])
|
||||||
print_cmd_ver(['darcs', '--version'])
|
print_stdout(['darcs', '--version'])
|
||||||
print_cmd_ver(['darcs', '--exact-version'], label='darcs-exact-version')
|
print_stdout(['darcs', '--exact-version'], label='darcs-exact-version')
|
||||||
print_cmd_ver(['7za'])
|
print_stdout(['7za'])
|
||||||
|
|
||||||
print_as_ver()
|
print_as_ver()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user