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

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

Initial commit of the cluster acceptance package.

  • Property svn:executable set to *
File size: 1.5 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
10
11def test(logfile):
12    start_time = time.time()
13
14    (cluster, domain) = util.get_hostname()
15
16    util.header(logfile, 'Dump of the acceptance test environment on %s.' % cluster)
17
18    # show the hostname
19    util.log_print_nl(logfile, 'Hostname: %s.%s' % (cluster, domain))
20    util.log_print_nl(logfile)
21
22    # show python version being used
23    util.log_print_nl(logfile, 'Python version: %s' % sys.version.replace('\n', ' '))
24    util.log_print_nl(logfile)
25
26    # show PYTHONPATH value
27    pythonpath = os.getenv('PYTHONPATH')
28    util.log_print_nl(logfile, 'PYTHONPATH: %s' % pythonpath)
29    util.log_print_nl(logfile)
30
31    # show contents of ~/.machines_<machine>
32    home = os.getenv('HOME')
33    machines_file = os.path.join(home, '.machines_%s' % cluster)
34    try:
35        fd = open(machines_file, 'r')
36        data = fd.read()
37        fd.close()
38    except:
39        data = '***** NO FILE FOUND *****\n'
40
41    util.log_print_nl(logfile, '%s:' % machines_file)
42    util.log_print_nl(logfile, '-' * 30)
43    util.log_print(logfile, data)
44    util.log_print_nl(logfile, '-' * 30)
45    util.log_print_nl(logfile)
46
47    util.footer(logfile, start_time)
48    return True
49
50
51if __name__ == '__main__':
52    logfile = 'test.log'
53    if len(sys.argv) > 1:
54        logfile = sys.argv[1]
55
56    try:
57        os.remove(logfile)
58    except:
59        pass
60
61    if not test(logfile):
62        sys.exit(10)
63
64    sys.exit(0)
Note: See TracBrowser for help on using the repository browser.