本文整理汇总了Python中psiturk.psiturk_config.PsiturkConfig.getboolean方法的典型用法代码示例。如果您正苦于以下问题:Python PsiturkConfig.getboolean方法的具体用法?Python PsiturkConfig.getboolean怎么用?Python PsiturkConfig.getboolean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类psiturk.psiturk_config.PsiturkConfig
的用法示例。
在下文中一共展示了PsiturkConfig.getboolean方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: scale_up_dynos
# 需要导入模块: from psiturk.psiturk_config import PsiturkConfig [as 别名]
# 或者: from psiturk.psiturk_config.PsiturkConfig import getboolean [as 别名]
def scale_up_dynos(id):
"""Scale up the Heroku dynos."""
# Load psiTurk configuration.
config = PsiturkConfig()
config.load_config()
dyno_type = config.get('Server Parameters', 'dyno_type')
num_dynos_web = config.get('Server Parameters', 'num_dynos_web')
num_dynos_worker = config.get('Server Parameters', 'num_dynos_worker')
log("Scaling up the dynos...")
subprocess.call(
"heroku ps:scale web=" + str(num_dynos_web) + ":" +
str(dyno_type) + " --app " + id, shell=True)
subprocess.call(
"heroku ps:scale worker=" + str(num_dynos_worker) + ":" +
str(dyno_type) + " --app " + id, shell=True)
clock_on = config.getboolean('Server Parameters', 'clock_on')
if clock_on:
subprocess.call(
"heroku ps:scale clock=1:" + dyno_type + " --app " + id,
shell=True)
示例2: PsiTurkRecruiter
# 需要导入模块: from psiturk.psiturk_config import PsiturkConfig [as 别名]
# 或者: from psiturk.psiturk_config.PsiturkConfig import getboolean [as 别名]
class PsiTurkRecruiter(Recruiter):
"""Recruit participants from Amazon Mechanical Turk."""
def __init__(self):
"""Set up the connection to MTurk and psiTurk web services."""
# load the configuration options
self.config = PsiturkConfig()
self.config.load_config()
class FakeExperimentServerController(object):
def is_server_running(self):
return "yes"
self.server = FakeExperimentServerController()
# Get keys from environment variables or config file.
self.aws_access_key_id = os.getenv("aws_access_key_id", self.config.get("AWS Access", "aws_access_key_id"))
self.aws_secret_access_key = os.getenv(
"aws_secret_access_key", self.config.get("AWS Access", "aws_secret_access_key")
)
self.aws_region = os.getenv("aws_region", self.config.get("AWS Access", "aws_region"))
def open_recruitment(self, n=1):
"""Open recruitment for the first HIT, unless it's already open."""
from psiturk.amt_services import MTurkServices, RDSServices
from psiturk.psiturk_shell import PsiturkNetworkShell
from psiturk.psiturk_org_services import PsiturkOrgServices
psiturk_access_key_id = os.getenv(
"psiturk_access_key_id", self.config.get("psiTurk Access", "psiturk_access_key_id")
)
psiturk_secret_access_id = os.getenv(
"psiturk_secret_access_id", self.config.get("psiTurk Access", "psiturk_secret_access_id")
)
web_services = PsiturkOrgServices(psiturk_access_key_id, psiturk_secret_access_id)
aws_rds_services = RDSServices(self.aws_access_key_id, self.aws_secret_access_key, self.aws_region)
self.amt_services = MTurkServices(
self.aws_access_key_id,
self.aws_secret_access_key,
self.config.getboolean("Shell Parameters", "launch_in_sandbox_mode"),
)
self.shell = PsiturkNetworkShell(
self.config,
self.amt_services,
aws_rds_services,
web_services,
self.server,
self.config.getboolean("Shell Parameters", "launch_in_sandbox_mode"),
)
try:
participants = Participant.query.all()
assert participants
except Exception:
# Create the first HIT.
self.shell.hit_create(
n,
self.config.get("HIT Configuration", "base_payment"),
self.config.get("HIT Configuration", "duration"),
)
else:
# HIT was already created, no need to recreate it.
print "Reject recruitment reopening: experiment has started."
def recruit_participants(self, n=1):
"""Extend the HIT to recruit more people."""
auto_recruit = os.environ["auto_recruit"] == "true"
if auto_recruit:
print "Starting Wallace's recruit_participants."
hit_id = str(Participant.query.with_entities(Participant.hitid).first().hitid)
print "hit_id is {}.".format(hit_id)
is_sandbox = self.config.getboolean("Shell Parameters", "launch_in_sandbox_mode")
if is_sandbox:
host = "mechanicalturk.sandbox.amazonaws.com"
else:
host = "mechanicalturk.amazonaws.com"
mturkparams = dict(
aws_access_key_id=self.aws_access_key_id, aws_secret_access_key=self.aws_secret_access_key, host=host
)
self.mtc = MTurkConnection(**mturkparams)
#.........这里部分代码省略.........
示例3: deploy_sandbox_shared_setup
# 需要导入模块: from psiturk.psiturk_config import PsiturkConfig [as 别名]
# 或者: from psiturk.psiturk_config.PsiturkConfig import getboolean [as 别名]
def deploy_sandbox_shared_setup(verbose=True, app=None, web_procs=1):
"""Set up Git, push to Heroku, and launch the app."""
if verbose:
out = None
else:
out = open(os.devnull, 'w')
(id, tmp) = setup_experiment(debug=False, verbose=verbose, app=app)
# Log in to Heroku if we aren't already.
log("Making sure that you are logged in to Heroku.")
ensure_heroku_logged_in()
# Change to temporary directory.
cwd = os.getcwd()
os.chdir(tmp)
# Commit Heroku-specific files to tmp folder's git repo.
cmds = ["git init",
"git add --all",
'git commit -m "Experiment ' + id + '"']
for cmd in cmds:
subprocess.call(cmd, stdout=out, shell=True)
time.sleep(0.5)
# Load psiTurk configuration.
config = PsiturkConfig()
config.load_config()
# Initialize the app on Heroku.
log("Initializing app on Heroku...")
subprocess.call(
"heroku apps:create " + id +
" --buildpack https://github.com/thenovices/heroku-buildpack-scipy",
stdout=out,
shell=True)
database_size = config.get('Database Parameters', 'database_size')
try:
if config.getboolean('Easter eggs', 'whimsical'):
whimsical = "true"
else:
whimsical = "false"
except:
whimsical = "false"
# Set up postgres database and AWS/psiTurk environment variables.
cmds = [
"heroku addons:create heroku-postgresql:{}".format(database_size),
"heroku pg:wait",
"heroku addons:create rediscloud:250",
"heroku addons:create papertrail",
"heroku config:set HOST=" +
id + ".herokuapp.com",
"heroku config:set aws_access_key_id=" +
config.get('AWS Access', 'aws_access_key_id'),
"heroku config:set aws_secret_access_key=" +
config.get('AWS Access', 'aws_secret_access_key'),
"heroku config:set aws_region=" +
config.get('AWS Access', 'aws_region'),
"heroku config:set psiturk_access_key_id=" +
config.get('psiTurk Access', 'psiturk_access_key_id'),
"heroku config:set psiturk_secret_access_id=" +
config.get('psiTurk Access', 'psiturk_secret_access_id'),
"heroku config:set auto_recruit=" +
config.get('Experiment Configuration', 'auto_recruit'),
"heroku config:set wallace_email_username=" +
config.get('Email Access', 'wallace_email_address'),
"heroku config:set wallace_email_key=" +
config.get('Email Access', 'wallace_email_password'),
"heroku config:set heroku_email_address=" +
config.get('Heroku Access', 'heroku_email_address'),
"heroku config:set heroku_password=" +
config.get('Heroku Access', 'heroku_password'),
"heroku config:set whimsical=" + whimsical,
]
for cmd in cmds:
subprocess.call(cmd + " --app " + id, stdout=out, shell=True)
# Set the notification URL in the cofig file to the notifications URL.
config.set(
"Server Parameters",
"notification_url",
"http://" + id + ".herokuapp.com/notifications")
#.........这里部分代码省略.........
示例4:
# 需要导入模块: from psiturk.psiturk_config import PsiturkConfig [as 别名]
# 或者: from psiturk.psiturk_config.PsiturkConfig import getboolean [as 别名]
heroku_files = [
"Procfile",
"requirements.txt",
"psiturkapp.py",
"worker.py",
"clock.py",
]
for filename in heroku_files:
src = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"heroku",
filename)
shutil.copy(src, os.path.join(dst, filename))
clock_on = config.getboolean('Server Parameters', 'clock_on')
# If the clock process has been disabled, overwrite the Procfile.
if not clock_on:
src = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"heroku",
"Procfile_no_clock")
shutil.copy(src, os.path.join(dst, "Procfile"))
frontend_files = [
"static/css/wallace.css",
"static/scripts/wallace.js",
"static/scripts/reqwest.min.js",
"templates/error_wallace.html",
"templates/launch.html",
示例5: PsiturkConfig
# 需要导入模块: from psiturk.psiturk_config import PsiturkConfig [as 别名]
# 或者: from psiturk.psiturk_config.PsiturkConfig import getboolean [as 别名]
# load the configuration options
config = PsiturkConfig()
config.load_config()
myauth = PsiTurkAuthorization(config) # if you want to add a password protect route use this
# explore the Blueprint
custom_code = Blueprint('custom_code', __name__, template_folder='templates', static_folder='static')
recaptcha_secret = <<<SECRET RECAPTCHA KEY GOES HERE>>>
# for bonuses
amt_services = MTurkServices(
config.get('AWS Access', 'aws_access_key_id'), \
config.get('AWS Access', 'aws_secret_access_key'),
config.getboolean('Shell Parameters', 'launch_in_sandbox_mode'))
# for bonuses
class WorkerAlreadyCredited(Exception):
pass
class CreditTransactionError(Exception):
pass
class WorkerNotRegistered(Exception):
pass
class NoAMTConnection(Exception):
pass
def yield_participants(condition):