-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.py
executable file
·75 lines (64 loc) · 2.07 KB
/
run.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
#!/usr/bin/env python
# Usage:
# ./run.py topology_plot data/v5.xml
import sys
sys.dont_write_bytecode = True
import inspect
import logging
def asciiview(args):
from diarc import parser
from ascii_view import ascii_view
from diarc import base_adapter
topology = parser.parseFile(args[0])
view = ascii_view.AsciiView()
adapter = base_adapter.BaseAdapter(topology, view)
adapter._update_view()
def qtview(args):
try:
import python_qt_binding.QtGui
except:
print "Error: python_qt_binding not installed."
print "Please install using `sudo pip install python_qt_binding`"
exit(-1)
from diarc import parser
from qt_view import qt_view
from diarc import base_adapter
topology = parser.parseFile(args[0])
app = python_qt_binding.QtGui.QApplication(sys.argv)
view = qt_view.QtView()
adapter = base_adapter.BaseAdapter(topology, view)
adapter._update_view()
view.activateWindow()
view.raise_()
sys.exit(app.exec_())
def rosview():
try:
import python_qt_binding.QtGui
except:
print "Error: python_qt_binding not installed."
print "Please install using `sudo pip install python_qt_binding`"
exit(-1)
import qt_view
import ros.ros_adapter
app = python_qt_binding.QtGui.QApplication([])
view = qt_view.QtView()
adapter = ros.ros_adapter.RosAdapter(view)
adapter.update_model()
view.activateWindow()
view.raise_()
sys.exit(app.exec_())
if __name__=="__main__":
available_tests = dict(inspect.getmembers(sys.modules[__name__],inspect.isfunction))
# Enable the next to rows to perform profiling
# rosview()
# exit()
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger('main')
if len(sys.argv) < 2 or sys.argv[1] not in available_tests:
print "Usage:\n ./test.py <test> [parameters]\n"
print "Tests available:",available_tests.keys()
exit(0)
elif len(sys.argv)>2:
available_tests[sys.argv[1]](sys.argv[2:])
else:
available_tests[sys.argv[1]]()