/usr/bin/opensesamerun is in opensesame 0.27.4-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 | #!/usr/bin/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/>.
"""
if __name__ == "__main__":
# First, load a minimum number of modules and show an empty app window. This
# gives the user the feeling of a snappy response.
import os, sys
# Change the working directory on Windows. Depending on whether the
# application has been frozen by py2exe or not we need to use a different
# method of deducing the name to the main script.
# See also http://www.py2exe.org/index.cgi/HowToDetermineIfRunningFromExe
if os.name == "nt":
import imp
if (hasattr(sys, "frozen") or hasattr(sys, "importers") or \
imp.is_frozen("__main__")):
path = os.path.dirname(sys.executable)
else:
path = os.path.dirname(__file__)
if path != '':
os.chdir(path)
if path not in sys.path:
sys.path.append(path)
import libopensesame.misc
import libopensesame.experiment
# Parse the command line options
options = libopensesame.misc.opensesamerun_options()
app = None
# If the command line options haven't provided sufficient information to
# run right away, present a GUI
while not libopensesame.misc.opensesamerun_ready(options):
# If PyQt4 is not available (e.g., this might be the case on Mac OS)
# give an error instead of showing a GUI. This makes sure that even
# without PyQt4, people can still run experiments.
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.")
sys.exit()
# Create the GUI and show it
import libqtopensesame.qtopensesamerun
if app == None:
app = QtGui.QApplication(sys.argv)
myapp = libqtopensesame.qtopensesamerun.qtopensesamerun(options)
QtCore.QObject.connect(app, QtCore.SIGNAL("sys.exit()"), myapp.close)
myapp.show()
app.exec_()
# Update the options from the GUI
options = myapp.options
# Exit if the GUI was canceled
if not myapp.run:
sys.exit()
if options.debug:
# In debug mode, don't try to catch any exceptions
exp = libopensesame.experiment.experiment("Experiment", options.experiment)
exp.set_subject(options.subject)
exp.fullscreen = options.fullscreen
exp.logfile = options.logfile
exp.run()
exp.end()
else:
# Try to parse the experiment from a file
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))
sys.exit()
# Set some options
exp.set_subject(options.subject)
exp.fullscreen = options.fullscreen
exp.logfile = options.logfile
# Initialize random number generator
import random
random.seed()
# Try to run the experiment
try:
exp.run()
except Exception as e:
# Try to nicely end the experiment, even though an exception occurred
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))
libopensesame.experiment.clean_up(exp.debug)
|