#!/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 ANUGAPATH value ANUGAPATH = os.getenv('ANUGAPATH') util.log_print_nl(logfile, 'ANUGAPATH environment variable = %s' % ANUGAPATH) # see if we can get a revision number for ANUGA source revision = None try: revision = get_revision_number() except: pass if revision is None: util.log_print_nl(logfile, "Can't get ANUGA revision number.") else: util.log_print_nl(logfile, "ANUGA revision number is %d." % revision) util.log_print_nl(logfile) # See if we are testing EQRM eqrm_path = os.getenv('ANUGAPATH') if eqrm_path: util.log_print_nl(logfile, 'Environment variable ANUGAPATH = %s' % eqrm_path) util.log_print_nl(logfile, 'EQRM will be tested below.') else: util.log_print_nl(logfile, 'Environment variable ANUGAPATH not set, not testing EQRM.') util.log_print_nl(logfile) ## # show contents of ./machines_ ## # NOT SURE THIS FILE HAS ANY MEANING ANYMORE!? ## 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) # display which nodes are considered 'bad' cluster_info = util.get_cluster_info(cluster) bad_node_list = cluster_info['bad_nodes'] if bad_node_list: util.log_print_nl(logfile, 'The following nodes are considered bad:') util.log_print(logfile, ' ') for n in bad_node_list: util.log_print(logfile, '%d ' % n) util.log_print_nl(logfile) else: util.log_print_nl(logfile, 'No nodes are considered bad.') 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)