forked from open-cogsci/OpenSesame
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopensesamerun
More file actions
executable file
·74 lines (56 loc) · 2.18 KB
/
Copy pathopensesamerun
File metadata and controls
executable file
·74 lines (56 loc) · 2.18 KB
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
#-*- coding:utf-8 -*-
"""
This file is part of OpenSesame.
OpenSesame is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenSesame is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenSesame. If not, see <http://www.gnu.org/licenses/>.
"""
import os
import os.path
import sys
import libqtopensesame.qtopensesamerun
import libopensesame.misc
import libopensesame.experiment
if __name__ == "__main__":
libopensesame.misc.change_working_dir()
options = libopensesame.misc.opensesamerun_options()
app = None
while not libopensesame.misc.opensesamerun_ready(options):
try:
from PyQt4 import QtGui, QtCore
except:
libopensesame.misc.messagebox("OpenSesame Run", "Incorrect or missing options.\n\nRun 'opensesame --help' from a terminal (or command prompt) to see a list of available options, or install Python Qt4 to enable the graphical user interface.")
quit()
if app == None:
app = QtGui.QApplication(sys.argv)
myapp = libqtopensesame.qtopensesamerun.qtopensesamerun(options)
QtCore.QObject.connect(app, QtCore.SIGNAL("quit()"), myapp.close)
myapp.show()
app.exec_()
options = myapp.options
if not myapp.run:
quit()
try:
exp = libopensesame.experiment.experiment("Experiment", options.experiment)
except libopensesame.exceptions.script_error as e:
libopensesame.misc.messagebox("OpenSesame Run", libopensesame.misc.strip_tags(e))
quit()
exp.set_subject(options.subject)
exp.fullscreen = options.fullscreen
exp.logfile = options.logfile
try:
exp.run()
except Exception as e:
try:
exp.end()
except Exception as f:
libopensesame.misc.messagebox("OpenSesame Run", libopensesame.misc.strip_tags(f))
libopensesame.misc.messagebox("OpenSesame Run", libopensesame.misc.strip_tags(e))