Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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()
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
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
# [] def do_debug
# [] def do_version
# [] def do_dev
# def do_config(self, arg):
# """
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
from psiturk.psiturk_shell import PsiturkNetworkShell
import psiturk.psiturk_shell as ps
import psiturk.experiment_server_controller
config = PsiturkConfig()
config.load_config()
config.set('Shell Parameters', 'persistent_history_file', '')
config.set('AWS Access','aws_access_key_id', 'YourAccessKeyId')
config.set('AWS Access','aws_secret_access_key', 'YourSecretAccessKey')
server = psiturk.experiment_server_controller.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 AWSAccessKeysNotSetError().message in out
def psiturk_shell(mocker):
import psiturk.psiturk_shell
mocker.patch.object(psiturk.psiturk_shell.PsiturkNetworkShell, 'get_intro_prompt', lambda *args, **kwargs: '')
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()
try:
func = getattr(self, 'help_' + arg)
except AttributeError:
try:
doc = getattr(self, 'do_' + arg).__doc__
if doc:
self.stdout.write("%s\n" % str(doc))
return
except AttributeError:
pass
self.stdout.write("%s\n" % str(self.nohelp % (arg,)))
return
func()
else:
# Modifications start here
names = dir(PsiturkNetworkShell)
super_names = dir(Cmd)
new_names = [m for m in names if m not in super_names]
help_struct = {}
cmds_psiTurk = []
cmds_super = []
for name in names:
if name[:5] == 'help_':
help_struct[name[5:]] = 1
names.sort()
prevname = ''
for name in names:
if name[:3] == 'do_':
if name == prevname:
continue
prevname = name
cmd = name[3:]
def complete_worker(self, text, line, begidx, endidx):
''' Tab-complete worker command. '''
return [i for i in PsiturkNetworkShell.worker_commands if
i.startswith(text)]