#!/bin/env python '''Testlet to dump the acceptance environment.''' import os import sys import time import test_utils as util name = 'Dump of the acceptance test environment' def test(logfile): (cluster, domain) = util.get_hostname() # show the hostname util.log_print_nl(logfile, 'Hostname: %s.%s' % (cluster, domain)) util.log_print_nl(logfile) # show value of PYTHON environment variable python_env_var = os.getenv('PYTHON', '') util.log_print_nl(logfile, 'PYTHON environment variable = %s' % python_env_var) if python_env_var == '': util.log_print_nl(logfile, "Assume 'export PYTHON=python'") util.log_print_nl(logfile) python_env_var = os.getenv('PYTHON', 'python') # show python version being used cmd = '%s -c "import sys;print sys.version"' % python_env_var fd = os.popen(cmd, 'r') python_version = fd.read() fd.close() util.log_print_nl(logfile, "Executing '$PYTHON' gives version: %s" % python_version.replace('\n', ' ')) util.log_print_nl(logfile) # show PYTHONPATH value pythonpath = os.getenv('PYTHONPATH') util.log_print_nl(logfile, 'PYTHONPATH environment variable = %s' % pythonpath) util.log_print_nl(logfile) # show contents of ./machines_ home = os.getenv('HOME') machines_file = os.path.join(home, '.machines_%s' % cluster) try: fd = open(machines_file, 'r') data = fd.read() fd.close() except: data = '***** NO FILE FOUND *****\n' util.log_print_nl(logfile, '%s:' % machines_file) util.log_print_nl(logfile, '-' * 30) util.log_print(logfile, data) util.log_print_nl(logfile, '-' * 30) util.log_print_nl(logfile) return True if __name__ == '__main__': logfile = 'test.log' if len(sys.argv) > 1: logfile = sys.argv[1] try: os.remove(logfile) except: pass if not test(logfile): sys.exit(10) sys.exit(0)