2009-02-19 08:35:58 +00:00
#! /usr/bin/env python
2010-06-05 16:29:32 +00:00
import locale , os , subprocess , sys
2010-05-04 04:56:43 +00:00
2010-05-16 05:01:22 +00:00
def print_platform ( ) :
try :
import platform
out = platform . platform ( )
print
print " platform: " , out . replace ( " \n " , " " )
2010-06-08 00:45:23 +00:00
if hasattr ( platform , ' linux_distribution ' ) :
print " linux_distribution: " , repr ( platform . linux_distribution ( ) )
2010-05-16 05:01:22 +00:00
except EnvironmentError , le :
sys . stderr . write ( " Got exception using ' platform ' : %s \n " % ( le , ) )
pass
2009-02-19 08:35:58 +00:00
2010-05-16 05:01:22 +00:00
def print_python_ver ( ) :
2010-05-21 09:43:13 +00:00
print " python: " , sys . version . replace ( " \n " , " " ) ,
print ' , maxunicode: ' + str ( sys . maxunicode ) ,
print ' , stdout.encoding: ' + str ( sys . stdout . encoding ) ,
print ' , stdin.encoding: ' + str ( sys . stdin . encoding ) ,
2010-06-05 16:29:32 +00:00
print ' , filesystem.encoding: ' + str ( sys . getfilesystemencoding ( ) ) ,
print ' , locale.getpreferredencoding: ' + str ( locale . getpreferredencoding ( ) ) ,
print ' , os.path.supports_unicode_filenames: ' + str ( os . path . supports_unicode_filenames ) ,
print ' , locale.defaultlocale: ' + str ( locale . getdefaultlocale ( ) ) ,
print ' , locale.locale: ' + str ( locale . getlocale ( ) )
2009-02-19 08:35:58 +00:00
2010-05-16 05:01:22 +00:00
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
2010-05-04 04:56:43 +00:00
2010-05-16 05:01:22 +00:00
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
2009-02-19 08:35:58 +00:00
2010-05-16 05:01:22 +00:00
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
2009-06-21 05:58:46 +00:00
2010-05-16 05:01:22 +00:00
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
2009-06-21 05:58:46 +00:00
2010-05-16 05:01:22 +00:00
print_platform ( )
2010-05-04 04:56:43 +00:00
2010-05-16 05:01:22 +00:00
print_python_ver ( )
2010-05-04 04:56:43 +00:00
2010-05-16 05:01:22 +00:00
print_cmd_ver ( [ ' buildbot ' , ' --version ' ] )
print_cmd_ver ( [ ' cl ' ] )
print_cmd_ver ( [ ' gcc ' , ' --version ' ] )
print_cmd_ver ( [ ' g++ ' , ' --version ' ] )
print_cmd_ver ( [ ' cryptest ' , ' V ' ] )
print_cmd_ver ( [ ' darcs ' , ' --version ' ] )
print_cmd_ver ( [ ' darcs ' , ' --exact-version ' ] , label = ' darcs-exact-version ' )
print_cmd_ver ( [ ' 7za ' ] )
2010-05-10 06:29:55 +00:00
2010-05-16 05:01:22 +00:00
print_as_ver ( )
2010-05-10 06:29:55 +00:00
2010-05-16 05:01:22 +00:00
print_setuptools_ver ( )
2010-05-10 06:29:55 +00:00
2010-05-16 05:01:22 +00:00
print_py_pkg_ver ( ' coverage ' )
print_py_pkg_ver ( ' trialcoverage ' )
print_py_pkg_ver ( ' setuptools_trial ' )
2010-06-07 05:16:18 +00:00
print_py_pkg_ver ( ' pyflakes ' )