-
Notifications
You must be signed in to change notification settings - Fork 95
/
check_env.py
executable file
·50 lines (39 loc) · 1.26 KB
/
check_env.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
"""Computational environment validation script for the 2014 SciPy Conference Tutorial:
Reproducible Research: Walking the Walk.
https://github.com/reproducible-research/scipy-tutorial-2014
"""
import sys
import subprocess
return_value = 0
required_packages = ['numpy', 'scipy', 'matplotlib', 'SimpleITK']
for package in required_packages:
print('Importing ' + package + ' ...')
try:
__import__(package, globals(), locals(), [], 0)
except ImportError:
print('Error: could not import ' + package)
return_value += 1
print('')
required_executables = ['git',
'dexy',
'ipython',
'latex',
'nosetests',
'mplayer']
for executable in required_executables:
print('Executing ' + executable + ' ...')
try:
process = subprocess.Popen([executable, '--help'],
stderr=subprocess.STDOUT,
stdout=subprocess.PIPE)
process.wait()
except OSError:
print('Error: could not execute ' + executable)
return_value += 1
if return_value is 0:
print('\nSuccess.')
else:
print('\nA defect was found in your environment, please see the messages ' +
'above.')
sys.exit(return_value)