forked from TUDelft-CNS-ATM/bluesky
-
Notifications
You must be signed in to change notification settings - Fork 14
/
check.py
148 lines (128 loc) · 4.02 KB
/
check.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/usr/bin/python
from __future__ import print_function
import traceback
print("This script checks the availability of the libraries required by BlueSky, and the capabilities of your system.")
print()
np = sp = mpl = qt = gl = glhw = pg = False
# Basic libraries
print("Checking for numpy ", end=' ')
try:
import numpy
except ImportError:
print("[FAIL]")
else:
np = True
print('[OK]')
print("Checking for scipy ", end=' ')
try:
import scipy
except ImportError:
print("[FAIL]")
else:
sp = True
print('[OK]')
print("Checking for matplotlib ", end=' ')
try:
import matplotlib
except ImportError:
print("[FAIL]")
else:
mpl = True
print('[OK]')
# Graphical libs and capabilities
print("Checking for pyqt ", end=' ')
try:
from PyQt5.QtCore import QT_VERSION_STR
from PyQt5.QtWidgets import QApplication
from PyQt5.QtOpenGL import QGLWidget, QGLFormat
qt = True
except ImportError:
print("[FAIL]")
if qt:
print("[QT {}]" .format(QT_VERSION_STR))
print("Checking for pyopengl ", end=' ')
try:
import OpenGL
import OpenGL.GL as ogl
except ImportError:
print("[FAIL]")
else:
v = OpenGL.__version__.split('.')
ver = float(v[0]) + 0.1 * int(v[1])
gl = (ver >= 3.1)
if gl:
print('[OK]')
else:
print('[FAIL]')
print('OpenGL module version should be at least 3.1.0')
print('OpenGL module version is [%s]' % OpenGL.__version__)
print("Checking GL capabilities ", end=' ')
app = QApplication([])
if not QGLFormat.hasOpenGL():
print('[FAIL]')
else:
print('[OK]')
print('GL Version at least 3.3 ', end=' ')
try:
f = QGLFormat()
f.setVersion(3, 3)
f.setProfile(QGLFormat.CoreProfile)
f.setDoubleBuffer(True)
QGLFormat.setDefaultFormat(f)
class GLTest(QGLWidget):
gl_version = 0.0
def __init__(self):
super(GLTest, self).__init__()
def initializeGL(self):
GLTest.gl_version = float(ogl.glGetString(ogl.GL_VERSION)[:3])
test = GLTest()
test.show()
if GLTest.gl_version >= 3.3:
print("[OK]")
glhw = True
else:
print("[FAIL]")
print("Supported GL version [%.1f]" % GLTest.gl_version)
except:
print('[FAIL]')
print('Could not determine GL version')
print("Checking for pyopengl-accelerate", end=' ')
try:
import OpenGL_accelerate
except ImportError:
print("[FAIL]")
else:
print('[OK]')
print("Checking for pygame ", end=' ')
try:
import pygame
except ImportError:
print('[FAIL]')
else:
pg = True
print('[OK]')
print()
if np and sp and mpl:
canrunqt = (qt and gl and glhw)
canrunpg = pg
if canrunpg or canrunqt:
print('You have all the required libraries to run BlueSky. You can use', end=' ')
if canrunpg and canrunqt:
print('both the QTGL and the pygame versions.')
else:
print('only the %s version.' % ('pygame' if canrunpg else 'QTGL'))
print("Checking bluesky modules")
try:
from bluesky import *
from bluesky.ui import *
from bluesky.stack import *
from bluesky.simulation import *
from bluesky.traffic import *
from bluesky.traffic.asas import *
from bluesky.traffic.performance import *
from bluesky.navdatabase import *
except Exception as err:
print(traceback.format_exc())
print("One or more BlueSky modules are not working properly, check the above error for more detail.")
else:
print("Successfully loaded all BlueSky modules. Start BlueSky by running BlueSky.py.")