1 """Top level of the application QUB Express.
2
3 Copyright 2008-2012 Research Foundation State University of New York
4 This file is part of QUB Express.
5
6 QUB Express is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 QUB Express is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License,
17 named LICENSE.txt, in the QUB Express program directory. If not, see
18 <http://www.gnu.org/licenses/>.
19
20
21 """
22
23
24
25
26 import uuid
27 import gobject
28 import multiprocessing
29 import os
30 import sys
31
32 QUBX_HOME_PATH = os.path.expanduser('~/.fitness')
33 APPNAME = 'Fitness'
34
38 actual_stdout, actual_stderr = sys.stdout, sys.stderr
39 sys.stdout, sys.stderr = StdNull(), StdNull()
40
41 multiprocessing.freeze_support()
42 gobject.threads_init()
43
44 import qubx.splash_main
45 qubx.splash_main.show_splash('Loading %s...' % APPNAME)
46
47 import qubx.tree
48 qubx.tree.CHOOSE_FLAVOR('numpy')
49
50
51 from qubx.cube import *
52
53 VERSION = "3.5.0"
54 QUBX_VERSION = qubx.global_namespace.QUBX_VERSION = VERSION
55
74
75
76
77
78 if __name__ == '__main__':
79 run_me_first()
80
81 parser = argparse.ArgumentParser()
82 parser.add_argument("-t", "--trace", dest="trace",
83 action="store_true",
84 default=False,
85 help="prints line-by-line trace for debug")
86 parser.add_argument("-s", "--startup-script", dest="startup_script",
87 action="store", default="",
88 help="on startup, executes a python file")
89 (args, extras) = parser.parse_known_args()
90 qubx.global_namespace.args = args
91 qubx.global_namespace.extras = extras
92 qubx.global_namespace.unknown_args = extras
93 qubx.global_namespace.DEBUG = DEBUG = False
94
95 if args.trace:
96 qubx.global_namespace.DEBUG = DEBUG = True
97 tracelog = open('/dev/shm/trace', 'w')
99 if event == "line":
100 lineno = frame.f_lineno
101 filename = frame.f_globals["__file__"]
102 if filename == "<stdin>":
103 filename = "<stdin> "
104 if (filename.endswith(".pyc") or
105 filename.endswith(".pyo")):
106 filename = filename[:-1]
107 name = frame.f_globals["__name__"]
108 line = linecache.getline(filename, lineno)
109 tracelog.write("%s:%s: %s\n" % (name, lineno, line.rstrip()))
110 tracelog.flush()
111 return traceit
112 sys.settrace(traceit)
113
114 try:
135 cube.Layout.OnToggleFace += show_sidebar_with_data
136 gobject.idle_add(cube.Tables.show_table, cube.Data.table)
137
138 app = FitnessApp(APPNAME, VERSION, '.fitness3', has_modeling=False, DEBUG=DEBUG, codename='fitness', adjust_layout=adjust_layout)
139 app.main(startup_script=args.startup_script or os.path.join(qubx.pyenv.env.folder, 'startup_script.py'))
140 except KeyboardInterrupt:
141 pass
142 except Exception, e:
143 dlg = gtk.MessageDialog(None, buttons=gtk.BUTTONS_OK,
144 flags=gtk.DIALOG_MODAL,
145 message_format = traceback.format_exc())
146 dlg.run()
147 dlg.destroy()
148
149 run_me_last()
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192