Ejemplo n.º 1
0
def experiment():
    """Yields a generic experiment to test generic functionality
    (implements dummy methods for abstract methods).

    """
    class TestExperiment(Experiment):
        def prepare_experiment(self):
            pass

        def run(self):
            pass

    data_dir = mkdtemp()
    config = absjoin(git_root(), "ramcontrol", "configs", "FR", "config.py")
    sconfig = absjoin(git_root(), "ramcontrol", "configs", "FR",
                      "FR5_config.py")
    EPLExperiment.parseArgs = lambda x: x
    epl_exp = EPLExperiment(archive=data_dir,
                            subject="R0001E",
                            config=config,
                            sconfig=sconfig,
                            fullscreen=False,
                            use_eeg=False)
    epl_exp.setup()
    epl_exp.setBreak()
    experiment = TestExperiment(epl_exp)
    yield experiment
    try:
        epl_exp.breakfunc(True, None, False)
    except SystemExit:  # breakfunc stupidly calls sys.exit
        pass
    finally:
        shutil.rmtree(data_dir, ignore_errors=True)
Ejemplo n.º 2
0
def main():
    config = ConfigParser()
    config.read("ramcontrol.ini")

    parser = ArgumentParser()
    parser.add_argument("-s", "--subject", help="Subject ID", default=None)
    parser.add_argument("-x", "--experiment", default=None, help="Experiment to run")
    parser.add_argument("-l", "--language",
                        choices=["english", "spanish"],
                        help="Language to use in experiment")
    parser.add_argument("-d", "--debug", action="store_true", default=False,
                        help="Enable debug mode")
    parser.add_argument("--no-fs", action="store_true", default=False,
                        help="Disable fullscreen mode")
    args = parser.parse_args()

    experiments = config["general"]["experiments"].split()

    if args.debug:
        print("!"*80)
        print("{:^80}".format("DEBUG MODE ENABLED!"))
        print("{:^80}".format("Restart NOW if this is a real experiment!!!"))
        print("!"*80)

    if args.subject is None:
        args.subject = get_subject()
    if args.experiment is None:
        args.experiment = get_experiment(experiments)
    if args.language is None:
        args.language = get_language(config["general"]["languages"].split())

    env = {
        "subject": args.subject,
        "experiment": args.experiment,
        "experiment_family": config.get(args.experiment, "family"),
        "language": args.language,

        "voiceserver": config[args.experiment].getboolean("voiceserver", fallback=False),

        "video_path": os.path.abspath(os.path.expanduser(config["videos"]["path"])),
        "data_path": absjoin("./data"),
        "ramcontrol_path": os.path.dirname(ramcontrol.__file__),

        "fullscreen": not (args.debug or args.no_fs),
        "debug": args.debug,
        "debug_options": config["debug"].items()
    }

    penv = os.environ.copy()
    penv["RAM_CONFIG"] = pickle.dumps(env)

    p = subprocess.Popen(["python", "-m", "ramcontrol.experiment"],
                         cwd=absjoin("."), env=penv)
    p.wait()
Ejemplo n.º 3
0
def test_absjoin():
    assert util.absjoin(".", "tests") == here