Пример #1
0
    def do_it():
        from psiturk.psiturk_shell import PsiturkNetworkShell
        import psiturk.experiment_server_controller as control
        from psiturk.psiturk_config import PsiturkConfig

        import psiturk.experiment_server_controller
        mocker.patch.object(psiturk.experiment_server_controller.ExperimentServerController, 'is_port_available', lambda *args, **kwargs: True)

        mocker.patch.object(PsiturkNetworkShell,'get_intro_prompt', lambda *args, **kwargs: '')
        mocker.patch.object(PsiturkNetworkShell,'update_hit_tally', lambda *args, **kwargs: None)
        mocker.patch.object(PsiturkNetworkShell,'_confirm_dialog', lambda *args, **kwargs: True)

        config = PsiturkConfig()
        config.load_config()
        server = control.ExperimentServerController(config)

        launch_in_sandbox_mode = True
        quiet = False
        shell = PsiturkNetworkShell(
            config, server,
            launch_in_sandbox_mode,
            quiet=quiet)
        shell.persistent_history_file = None
        shell.echo = True
        stubber.assert_no_pending_responses()
        return shell
Пример #2
0
def run(script=None, execute=None, testfile=None, quiet=False):
    using_libedit = 'libedit' in readline.__doc__
    if using_libedit:
        self.poutput(
            colorize(
                '\n'.join([
                    'libedit version of readline detected.',
                    'readline will not be well behaved, which may cause all sorts',
                    'of problems for the psiTurk shell. We highly recommend installing',
                    'the gnu version of readline by running "sudo pip install gnureadline".',
                    'Note: "pip install readline" will NOT work because of how the OSX',
                    'pythonpath is structured.'
                ]), 'red', False))
    # Drop arguments which were already processed in command_line.py
    sys.argv = [sys.argv[0]]
    #opt = docopt(__doc__, sys.argv[1:])
    config = PsiturkConfig()
    config.load_config()
    server = control.ExperimentServerController(config)
    shell = PsiturkNetworkShell(config,
                                server,
                                config.getboolean('Shell Parameters',
                                                  'launch_in_sandbox_mode'),
                                quiet=quiet)

    if script:
        shell.runcmds_plus_hooks(['load {}'.format(script)])
    elif execute:
        shell.runcmds_plus_hooks([execute])
    elif testfile:
        shell.run_transcript_tests(testfile)
    else:
        shell.cmdloop()
Пример #3
0
def test_awskeys_invalid(capfd):
    import psiturk.experiment_server_controller as control
    from psiturk.psiturk_config import PsiturkConfig
    from psiturk.psiturk_shell import PsiturkNetworkShell
    import psiturk.psiturk_shell as ps

    config = PsiturkConfig()
    config.load_config()
    config.set('Shell Parameters', 'persistent_history_file', '')
    config.set('AWS Access', 'aws_access_key_id', '')
    config.set('AWS Access', 'aws_secret_access_key', '')
    server = control.ExperimentServerController(config)

    launch_in_sandbox_mode = True
    quiet = False
    try:
        shell = PsiturkNetworkShell(config,
                                    server,
                                    launch_in_sandbox_mode,
                                    quiet=quiet)
    except SystemExit:
        pass

    out, err = capfd.readouterr()
    assert NoMturkConnectionError().message in out
Пример #4
0
def run(script=None, execute=None, testfile=None, quiet=False):
    try:
        using_libedit = 'libedit' in readline.__doc__
        if using_libedit:
            print('\n'.join([
                'libedit version of readline detected.',
                'readline will not be well behaved, which may cause all sorts',
                'of problems for the psiTurk shell. We highly recommend installing',
                'the gnu version of readline by running "sudo pip install gnureadline".',
                'Note: "pip install readline" will NOT work because of how the OSX',
                'pythonpath is structured.'
            ]))
    except TypeError:
        pass  # pyreadline doesn't have anything for __doc__
    # Drop arguments which were already processed in command_line.py
    sys.argv = [sys.argv[0]]
    config = PsiturkConfig()
    config.load_config()
    server = control.ExperimentServerController(config)
    shell = PsiturkNetworkShell(config,
                                server,
                                mode=config.get('Shell Parameters',
                                                'launch_in_mode'),
                                quiet=quiet)

    if script:
        shell.runcmds_plus_hooks([f'load {script}'])
    elif execute:
        shell.runcmds_plus_hooks([execute])
    else:
        shell.cmdloop()
Пример #5
0
    os.chdir('..')
    shutil.rmtree('psiturk-example', ignore_errors=True)


do_setup()

import psiturk.experiment_server_controller as control
from psiturk.psiturk_config import PsiturkConfig
from psiturk.psiturk_shell import PsiturkNetworkShell


try:

    config = PsiturkConfig()
    config.load_config()
    server = control.ExperimentServerController(config)

    launch_in_sandbox_mode = True
    quiet = False

    shell = PsiturkNetworkShell(
        config, server,
        launch_in_sandbox_mode,
        quiet=quiet)
        
    shell.persistent_history_file = None

    # #########################
    # all `do_` commands:
    # #################
    # [] def do_psiturk_status