Example #1
0
def main():
    """The main routine, which is called automatically by pgs4a"""

    if android is not None:
        sys.stdout = stdout_file(sys.stdout)

    # First check if an autorun file has been specified. This is a yaml file
    # with the experiment path, subject nr, and logfile in it.
    for folder in sdcard_folders:
        path = os.path.join(folder, 'opensesame-autorun.yml')
        print(path)
        if os.path.exists(path):
            d = yaml.load(open(path))
            experiment_path = d['experiment']
            subject_nr = d['subject_nr']
            logfile = d['logfile']
            break
    # If no autorun file has been specified, we launch the menu experiment.
    else:
        src = 'opensesame_resources/android/menu.osexp'
        print('Launching %s' % src)
        menu = experiment('Experiment', src)
        menu.experiment_path = None
        menu.run()
        menu.end()
        clean_up(menu.debug)
        experiment_path = menu._experiment
        subject_nr = menu._subject_nr
        logfile = menu._logfile

    # Next run the actual experiment!
    try:
        exp = experiment(name='Experiment',
                         string=experiment_path,
                         experiment_path=os.path.dirname(experiment_path))
    except Exception as e:
        for s in traceback.format_exc(e).split("\n"):
            print(s)
    print('Launching %s' % experiment_path)
    exp.set_subject(subject_nr)
    exp.logfile = logfile

    # Capture exceptions and write them to the standard output so they can be
    # inspected
    try:
        exp.run()
    except Exception as e:
        for s in traceback.format_exc(e).split("\n"):
            print(s)
    try:
        exp.end()
    except Exception as e:
        for s in traceback.format_exc(e).split("\n"):
            print(s)

    clean_up(exp.debug)
    pygame.display.quit()
Example #2
0
def main():

	"""The main routine, which is called automatically by pgs4a"""

	if android is not None:
		sys.stdout = stdout_file(sys.stdout)

	# First check if an autorun file has been specified. This is a yaml file
	# with the experiment path, subject nr, and logfile in it.
	for folder in sdcard_folders:
		path = os.path.join(folder, 'opensesame-autorun.yml')
		print(path)
		if os.path.exists(path):
			d = yaml.load(open(path))
			experiment_path = d['experiment']
			subject_nr = d['subject_nr']
			logfile = d['logfile']
			break
	# If no autorun file has been specified, we launch the menu experiment.
	else:
		src = 'opensesame_resources/android/menu.osexp'
		print('Launching %s' % src)
		menu = experiment('Experiment', src)
		menu.experiment_path = None
		menu.run()
		menu.end()
		clean_up(menu.debug)
		experiment_path = menu._experiment
		subject_nr = menu._subject_nr
		logfile = menu._logfile

	# Next run the actual experiment!
	try:
		exp = experiment(name='Experiment', string=experiment_path,
			experiment_path=os.path.dirname(experiment_path))
	except Exception as e:
		for s in traceback.format_exc(e).split("\n"):
			print(s)
	print('Launching %s' % experiment_path)
	exp.set_subject(subject_nr)
	exp.logfile = logfile

	# Capture exceptions and write them to the standard output so they can be
	# inspected
	try:
		exp.run()
	except Exception as e:
		for s in traceback.format_exc(e).split("\n"):
			print(s)
	try:
		exp.end()
	except Exception as e:
		for s in traceback.format_exc(e).split("\n"):
			print(s)

	clean_up(exp.debug)
	pygame.display.quit()
def main():
	
	"""The main routine, which is called automatically by pgs4a"""

	sys.argv.append('--debug')	
	if android != None:		
		sys.stdout = stdout_file(sys.stdout)
	# Instead of calling the menu, we skip straight to opening our experiment
		
	src = 'resources/android/AndroidReady.opensesame'
	print 'Launching %s' % src
	exp = experiment('Experiment', src)
	exp.subject_nr = 0
	exp.logfile = 'resources/android/log.csv'
	print exp
	#exp.run()
	#exp.end()
	#clean_up(exp.debug)	
	
	# The following used to set parameters in the experiement.
	# Although not currently used, some of it may be useful in future.
	#exp.subject_nr = menu._subject_nr
	#exp.logfile = menu._logfile
	
	# Capture exceptions and write them to the standard output so they can be
	# inspected
	try:
		exp.run()		
	except Exception as e:
		for s in traceback.format_exc(e).split("\n"):
			print s		
	try:
		exp.end()
	except Exception as e:
		for s in traceback.format_exc(e).split("\n"):
			print s
	
	clean_up(exp.debug)		
	pygame.display.quit()
def main():
	
	"""The main routine, which is called automatically by pgs4a"""

	sys.argv.append('--debug')	
	if android != None:		
		sys.stdout = stdout_file(sys.stdout)
		
	# First start the menu experiment	
	src = 'resources/android/menu.opensesame'
	print 'Launching %s' % src
	menu = experiment('Experiment', src)
	menu.run()
	menu.end()
	clean_up(menu.debug)	
	
	# Next run the actual experiment!
	exp = experiment('Experiment', menu._experiment)
	print 'Launching %s' % menu._experiment
	exp.subject_nr = menu._subject_nr
	exp.logfile = menu._logfile
	
	# Capture exceptions and write them to the standard output so they can be
	# inspected
	try:
		exp.run()		
	except Exception as e:
		for s in traceback.format_exc(e).split("\n"):
			print s		
	try:
		exp.end()
	except Exception as e:
		for s in traceback.format_exc(e).split("\n"):
			print s
	
	clean_up(exp.debug)		
	pygame.display.quit()
def main():
    """The main routine, which is called automatically by pgs4a"""

    sys.argv.append('--debug')
    if android != None:
        sys.stdout = stdout_file(sys.stdout)

    # First start the menu experiment
    src = 'resources/android/menu.opensesame'
    print 'Launching %s' % src
    menu = experiment('Experiment', src)
    menu.run()
    menu.end()
    clean_up(menu.debug)

    # Next run the actual experiment!
    exp = experiment('Experiment', menu._experiment)
    print 'Launching %s' % menu._experiment
    exp.subject_nr = menu._subject_nr
    exp.logfile = menu._logfile

    # Capture exceptions and write them to the standard output so they can be
    # inspected
    try:
        exp.run()
    except Exception as e:
        for s in traceback.format_exc(e).split("\n"):
            print s
    try:
        exp.end()
    except Exception as e:
        for s in traceback.format_exc(e).split("\n"):
            print s

    clean_up(exp.debug)
    pygame.display.quit()