Archived
Initial commit
This commit is contained in:
commit
d89b82be4a
103 files changed
+23110
No files matched your search
@@ -0,0 +1,121 @@
|
||||
import tools.settings as settings
|
||||
import logging
|
||||
import os
|
||||
from fishy.expe_run import main as fishy_main
|
||||
from gender.gender_run import main as gender_main
|
||||
# from emotion.emotion_run import main as emotion_main
|
||||
from crm.crm_run import main as crm_main
|
||||
from naoqi import ALBroker
|
||||
from tools.exit_condition import ExitExperimentModule
|
||||
import tools.settings as settings
|
||||
import pathlib
|
||||
|
||||
VERSION = 20202801
|
||||
expe_exit = None
|
||||
|
||||
|
||||
def setup_logger(name, log_file, level=logging.INFO):
|
||||
"""To setup as many loggers as you want"""
|
||||
formatter = logging.Formatter('%(levelname)s:%(message)s')
|
||||
handler = logging.FileHandler(log_file)
|
||||
handler.setFormatter(formatter)
|
||||
|
||||
logger = logging.getLogger(name)
|
||||
logger.setLevel(level)
|
||||
logger.addHandler(handler)
|
||||
logger.propagate = False
|
||||
|
||||
return logger
|
||||
|
||||
|
||||
def pickaMain(subject,
|
||||
game,
|
||||
phase,
|
||||
lang,
|
||||
p_exists,
|
||||
ip='127.0.0.1',
|
||||
port=9559,
|
||||
broker=False,
|
||||
cel_id=None):
|
||||
global expe_exit
|
||||
settings.task_id = cel_id
|
||||
print settings.task_id
|
||||
if not os.path.exists('./calibration.mat'):
|
||||
raise "Calibration has not been done for any of the sound files yet. \
|
||||
Please do this before before continuing with the PICKA experiment."
|
||||
|
||||
try:
|
||||
if not broker:
|
||||
myBroker = ALBroker("myBroker", "0.0.0.0", 0, str(ip), port)
|
||||
expe_exit = ExitExperimentModule("expe_exit", myBroker, lang)
|
||||
pass
|
||||
else:
|
||||
gameBroker = ALBroker("gameBroker", "0.0.0.1", 0, str(ip), port)
|
||||
except RuntimeError as e:
|
||||
print e
|
||||
pass
|
||||
|
||||
options = {}
|
||||
p_exists = p_exists == 'true'
|
||||
if game.lower() == "fishy":
|
||||
fishy_main(options, subject, phase, lang, p_exists, ip, port)
|
||||
elif game.lower() == "gender":
|
||||
gender_main(options, subject, phase, lang, p_exists, ip, port)
|
||||
elif game.lower() == "emotion":
|
||||
emotion_main(options, subject, phase, lang, p_exists, ip, port)
|
||||
elif game.lower() == "crm":
|
||||
crm_main(options, subject, phase, lang, p_exists, ip, port)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description="The main script used to run SAM",
|
||||
epilog=
|
||||
"Written by Luke Meyer <l.meyer.5@student.rug.nl>, adapted from MATLAB script by Etienne Gaudrain <etienne.gaudrain@cnrs.fr>\nCopyright 2017 CNRS (FR), UMCG (NL)",
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
parser.add_argument('-ip',
|
||||
'--ipadress',
|
||||
help="The ipadress of SAM.",
|
||||
default='127.0.0.1')
|
||||
parser.add_argument('-pp',
|
||||
'--port',
|
||||
help="Port that SAM has open for connection.",
|
||||
default=9559,
|
||||
type=int)
|
||||
parser.add_argument('-g',
|
||||
'--game',
|
||||
help="The game for the current experiment.",
|
||||
choices=["gender", "fishy", "emotion", "crm"],
|
||||
required=True)
|
||||
parser.add_argument('--version',
|
||||
help="Displays current version",
|
||||
action='version',
|
||||
version='Version = {}'.format(VERSION))
|
||||
parser.add_argument('-s',
|
||||
'--subject',
|
||||
help="Name of the subject perfomring the test.",
|
||||
required=True)
|
||||
parser.add_argument('-p',
|
||||
'--phase',
|
||||
help="Phase of testing. Test or training",
|
||||
required=True)
|
||||
parser.add_argument(
|
||||
'-l',
|
||||
'--lang',
|
||||
help="Language in which experiment should be conducted.",
|
||||
default="EN",
|
||||
choices=["EN", "NL"],
|
||||
required=True)
|
||||
parser.add_argument(
|
||||
'-e',
|
||||
'--file_exists',
|
||||
help=
|
||||
"Optional parameter if it is already known that a participant's results file already exists or not."
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
pickaMain(args.subject, args.game, args.phase, args.lang, args.file_exists,
|
||||
args.ipadress, 9559)
|
||||
Reference in new issue
Block a user