swc-installation-test-2.py: Prefer distro to platform.linux_distribution
[swc-setup-installation-test.git] / swc-installation-test-1.py
1 #!/usr/bin/env python
2
3 """Test script to check required Python version.
4
5 Execute this code at the command line by typing:
6
7   python swc-installation-test-1.py
8
9 How to get a command line:
10
11 - On OSX run this with the Terminal application.
12
13 - On Windows, go to the Start menu, select 'Run' and type 'cmd'
14 (without the quotes) to run the 'cmd.exe' Windows Command Prompt.
15
16 - On Linux, either use your login shell directly, or run one of a
17   number of graphical terminals (e.g. 'xterm', 'gnome-terminal', ...).
18
19 For some screen shots, see:
20
21   http://software-carpentry.org/setup/terminal.html
22
23 Run the script and follow the instructions it prints at the end.  If
24 you see an error saying that the 'python' command was not found, than
25 you may not have any version of Python installed.  See:
26
27   http://www.python.org/download/releases/2.7.3/#download
28
29 for installation instructions.
30
31 This test is separate to avoid Python syntax errors parsing the more
32 elaborate `swc-installation-test-2.py`.
33 """
34
35 import sys as _sys
36
37
38 __version__ = '0.1'
39
40
41 def check():
42     if _sys.version_info < (2, 6):
43         print('check for Python version (python):')
44         print('outdated version of Python: ' + _sys.version)
45         return False
46     return True
47
48
49 if __name__ == '__main__':
50     if check():
51         print('Passed')
52     else:
53         print('Failed')
54         print('Install a current version of Python!')
55         print('http://www.python.org/download/releases/2.7.3/#download')
56         _sys.exit(1)