source: branches/numpy_misc/tools/acceptance_tests/test_dump_python_environment.py @ 7230

Last change on this file since 7230 was 7230, checked in by rwilson, 15 years ago

Removed references to machines_* files.

  • Property svn:executable set to *
File size: 3.2 KB
Line 
1#!/bin/env python
2
3'''Testlet to dump the acceptance environment.'''
4
5import os
6import sys
7import time
8import test_utils as util
9
10name = 'Dump of the acceptance test environment'
11
12def test(logfile):
13    (cluster, domain) = util.get_hostname()
14
15    # show the hostname
16    util.log_print_nl(logfile, 'Hostname: %s.%s' % (cluster, domain))
17    util.log_print_nl(logfile)
18
19    # show value of PYTHON environment variable
20    python_env_var = os.getenv('PYTHON', '')
21    util.log_print_nl(logfile, 'PYTHON environment variable = %s' % python_env_var)
22    if python_env_var == '':
23        util.log_print_nl(logfile, "Assume 'export PYTHON=python'")
24    util.log_print_nl(logfile)
25    python_env_var = os.getenv('PYTHON', 'python')
26
27    # show python version being used
28    cmd = '%s -c "import sys;print sys.version"' % python_env_var
29    fd = os.popen(cmd, 'r')
30    python_version = fd.read()
31    fd.close() 
32    util.log_print_nl(logfile, "Executing '$PYTHON' gives version: %s" % python_version.replace('\n', ' '))
33    util.log_print_nl(logfile)
34
35    # show PYTHONPATH value
36    pythonpath = os.getenv('PYTHONPATH')
37    util.log_print_nl(logfile, 'PYTHONPATH environment variable = %s' % pythonpath)
38
39    # see if we can get a revision number for ANUGA source
40    revision = None
41    try:
42        revision = get_revision_number()
43    except:
44        pass
45    if revision is None:
46        util.log_print_nl(logfile, "Can't get ANUGA revision number.")
47    else:
48        util.log_print_nl(logfile, "ANUGA revision number is %d." % revision)
49    util.log_print_nl(logfile)
50
51    # See if we are testing EQRM
52    eqrm_path = os.getenv('EQRMPATH')
53    if eqrm_path:
54        util.log_print_nl(logfile, 'Environment variable EQRMPATH = %s' % eqrm_path)
55        util.log_print_nl(logfile, 'EQRM will be tested below.')
56    else:
57        util.log_print_nl(logfile, 'Environment variable EQRMPATH not set, not testing EQRM.')
58    util.log_print_nl(logfile)
59
60##    # show contents of ./machines_<machine>
61##    # NOT SURE THIS FILE HAS ANY MEANING ANYMORE!?
62##    home = os.getenv('HOME')
63##    machines_file = os.path.join(home, '.machines_%s' % cluster)
64##    try:
65##        fd = open(machines_file, 'r')
66##        data = fd.read()
67##        fd.close()
68##    except:
69##        data = '***** NO FILE FOUND *****\n'
70##
71##    util.log_print_nl(logfile, '%s:' % machines_file)
72##    util.log_print_nl(logfile, '-' * 30)
73##    util.log_print(logfile, data)
74##    util.log_print_nl(logfile, '-' * 30)
75##    util.log_print_nl(logfile)
76
77    # display which nodes are considered 'bad'
78    cluster_info = util.get_cluster_info(cluster)
79    bad_node_list = cluster_info['bad_nodes']
80    if bad_node_list:
81        util.log_print_nl(logfile, 'The following nodes are considered bad:')
82        util.log_print(logfile, '    ')
83        for n in bad_node_list:
84            util.log_print(logfile, '%d  ' % n)
85        util.log_print_nl(logfile)
86    else:
87        util.log_print_nl(logfile, 'No nodes are considered bad.')
88    util.log_print_nl(logfile)
89
90
91    return True
92
93
94if __name__ == '__main__':
95    logfile = 'test.log'
96    if len(sys.argv) > 1:
97        logfile = sys.argv[1]
98
99    try:
100        os.remove(logfile)
101    except:
102        pass
103
104    if not test(logfile):
105        sys.exit(10)
106
107    sys.exit(0)
Note: See TracBrowser for help on using the repository browser.