3 import locale, os, subprocess, sys, traceback
6 return s.replace("\n", " ").replace("\r", "")
12 out = platform.platform()
13 print "platform:", foldlines(out)
14 if hasattr(platform, 'linux_distribution'):
15 print "linux_distribution:", repr(platform.linux_distribution())
16 except EnvironmentError:
17 sys.stderr.write("\nGot exception using 'platform'. Exception follows\n")
18 traceback.print_exc(file=sys.stderr)
22 def print_python_ver():
24 print "python:", foldlines(sys.version)
25 print 'maxunicode: ' + str(sys.maxunicode)
27 def print_python_encoding_settings():
28 print_stderr([sys.executable, '-c', 'import sys; print >>sys.stderr, sys.stdout.encoding'], label='sys.stdout.encoding')
29 print_stdout([sys.executable, '-c', 'import sys; print sys.stderr.encoding'], label='sys.stderr.encoding')
31 print 'filesystem.encoding: ' + str(sys.getfilesystemencoding())
32 print 'locale.getpreferredencoding: ' + str(locale.getpreferredencoding())
33 print 'os.path.supports_unicode_filenames: ' + str(os.path.supports_unicode_filenames)
35 print 'locale.defaultlocale: ' + str(locale.getdefaultlocale())
37 print 'got exception from locale.getdefaultlocale(): ', e
38 print 'locale.locale: ' + str(locale.getlocale())
40 def print_stdout(cmdlist, label=None):
43 res = subprocess.Popen(cmdlist, stdin=open(os.devnull),
44 stdout=subprocess.PIPE).communicate()[0]
47 print label + ': ' + foldlines(res)
48 except EnvironmentError:
49 sys.stderr.write("\nGot exception invoking '%s'. Exception follows.\n" % (cmdlist[0],))
50 traceback.print_exc(file=sys.stderr)
54 def print_stderr(cmdlist, label=None):
57 res = subprocess.Popen(cmdlist, stdin=open(os.devnull),
58 stderr=subprocess.PIPE).communicate()[1]
61 print label + ': ' + foldlines(res)
62 except EnvironmentError:
63 sys.stderr.write("\nGot exception invoking '%s'. Exception follows\n" % (cmdlist[0],))
64 traceback.print_exc(file=sys.stderr)
70 if os.path.exists('a.out'):
71 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'."
74 res = subprocess.Popen(['as', '-version'], stdin=open(os.devnull),
75 stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
76 print 'as: ' + foldlines(res[0]+' '+res[1])
77 if os.path.exists('a.out'):
79 except EnvironmentError:
80 sys.stderr.write("\nGot exception invoking '%s'. Exception follows.\n" % ('as',))
81 traceback.print_exc(file=sys.stderr)
85 def print_setuptools_ver():
89 out = str(pkg_resources.require("setuptools"))
90 print "setuptools:", foldlines(out)
91 except (ImportError, EnvironmentError):
92 sys.stderr.write("\nGot exception using 'pkg_resources' to get the version of setuptools. Exception follows\n")
93 traceback.print_exc(file=sys.stderr)
97 def print_py_pkg_ver(pkgname):
101 out = str(pkg_resources.require(pkgname))
102 print pkgname + ': ' + foldlines(out)
103 except (ImportError, EnvironmentError):
104 sys.stderr.write("\nGot exception using 'pkg_resources' to get the version of %s. Exception follows.\n" % (pkgname,))
105 traceback.print_exc(file=sys.stderr)
108 except pkg_resources.DistributionNotFound:
109 sys.stderr.write("\npkg_resources reported no %s package installed. Exception follows.\n" % (pkgname,))
110 traceback.print_exc(file=sys.stderr)
118 print_stdout(['locale'])
119 print_python_encoding_settings()
121 print_stdout(['buildbot', '--version'])
123 print_stdout(['gcc', '--version'])
124 print_stdout(['g++', '--version'])
125 print_stdout(['cryptest', 'V'])
126 print_stdout(['darcs', '--version'])
127 print_stdout(['darcs', '--exact-version'], label='darcs-exact-version')
128 print_stdout(['7za'])
129 print_stdout(['flappclient', '--version'])
133 print_setuptools_ver()
135 print_py_pkg_ver('coverage')
136 print_py_pkg_ver('trialcoverage')
137 print_py_pkg_ver('setuptools_trial')
138 print_py_pkg_ver('pyflakes')
139 print_py_pkg_ver('zope.interface')
140 print_py_pkg_ver('setuptools_darcs')
141 print_py_pkg_ver('darcsver')