+ changed check for intial setting of old_w. (matrix != None does not work in cvxopt)
[qpalma.git] / tests / test_qpalma_installation.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # Written (W) 2008 Fabio De Bona
10 # Copyright (C) 2008 Max-Planck-Society
11
12 #
13 # This file performs a lot of checks in order to verify the installation of
14 # QPalma
15 #
16
17 import os
18 import sys
19 import unittest
20
21 from test_approximation import TestApproximation
22 #from test_qpalma import TestQPalmaPrediction
23 from test_utils import TestQPalmaPrediction
24
25 SUCCESS = True
26
27 def check_for_module(module_name):
28
29 try:
30 exec("import %s"%module_name)
31 except:
32 return False
33 sys.exc_info()
34
35 return True
36
37
38 if __name__ == '__main__':
39
40
41
42 log_fn = 'error.log'
43
44 if os.path.exists(log_fn):
45 os.remove(log_fn)
46
47 out_fh = open(log_fn,'w+')
48
49 print '\nChecking if your installation was successful...'
50
51 print '\nChecking for needed modules...\n'
52
53
54 module_list = ['numpy','DRMAA','Genefinding','pythongrid','QPalmaDP','qpalma']
55
56 for mod in module_list:
57 status = check_for_module(mod)
58 if status:
59 mes = "Successful!"
60 else:
61 mes = "Failed!"
62 SUCCESS = False
63
64 line = 'Status of module %s:\t%s'%(mod,mes)
65 print line
66 out_fh.write(line+'\n')
67
68 print '\nChecking for optional modules...\n'
69
70
71 solver_installed = False
72
73 module_list = ['pycplex', 'cvxopt', 'pymosek']
74
75 for mod in module_list:
76 status = check_for_module(mod)
77 solver_installed = solver_installed or status
78 line = 'Status of module %s:\t%s'%(mod,str(status))
79 print line
80 out_fh.write(line+'\n')
81
82 if not solver_installed:
83 print '\n'+'#'*80
84 print '\nNOTE: There are no solvers installed!'
85 print 'You will only be able to use QPalma in \'predict\' mode.\n'
86 print '#'*80
87
88 # after checking the modules we run some simple testcases on QPalma.
89 #data_suite = unittest.TestLoader().loadTestsFromTestCase(TestSequenceUtils)
90 #approximation_suite = unittest.TestLoader().loadTestsFromTestCase(TestApproximation)
91 #prediction_suite = unittest.TestLoader().loadTestsFromTestCase(TestQPalmaPrediction)
92
93 #all_suites = unittest.TestSuite([data_suite, approximation_suite, prediction_suite])
94 #test_result = unittest.TextTestRunner(verbosity=2).run(all_suites)
95 #test_status = test_result.wasSuccessful()
96 test_status = True
97
98 #print 'TEST STATUS is %s' % str(test_status)
99
100 if SUCCESS and test_status:
101 print '\n\n--- All checks where successful!! ---\n\n'
102 else:
103 print '\n\n--- Send the file error.log to qpalma@tuebingen.mpg.de ---\n\n'
104 env = os.environ
105 lines = ''
106 for var in ['PATH','LD_LIBRARY_PATH','PYTHONPATH']:
107 lines += '%s=%s\n'%(var,env[var])
108 out_fh.write(lines)
109
110 out_fh.close()