当前位置: 首页>>代码示例>>Python>>正文


Python PsiturkConfig.get方法代码示例

本文整理汇总了Python中psiturk.psiturk_config.PsiturkConfig.get方法的典型用法代码示例。如果您正苦于以下问题:Python PsiturkConfig.get方法的具体用法?Python PsiturkConfig.get怎么用?Python PsiturkConfig.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在psiturk.psiturk_config.PsiturkConfig的用法示例。


在下文中一共展示了PsiturkConfig.get方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ad_address

# 需要导入模块: from psiturk.psiturk_config import PsiturkConfig [as 别名]
# 或者: from psiturk.psiturk_config.PsiturkConfig import get [as 别名]
def ad_address(mode, hit_id):

    if mode == "debug":
        address = '/complete'
    elif mode in ["sandbox", "live"]:
        CONFIG = PsiturkConfig()
        CONFIG.load_config()
        username = os.getenv('psiturk_access_key_id', CONFIG.get("psiTurk Access", "psiturk_access_key_id"))
        password = os.getenv('psiturk_secret_access_id', CONFIG.get("psiTurk Access", "psiturk_secret_access_id"))
        try:
            req = requests.get('https://api.psiturk.org/api/ad/lookup/' + hit_id,
                               auth=(username, password))
        except:
            raise ValueError('api_server_not_reachable')
        else:
            if req.status_code == 200:
                hit_address = req.json()['ad_id']
            else:
                raise ValueError("something here")
        if mode == "sandbox":
            address = 'https://sandbox.ad.psiturk.org/complete/' + str(hit_address)
        elif mode == "live":
            address = 'https://ad.psiturk.org/complete/' + str(hit_address)
    else:
        raise ValueError("Unknown mode: {}".format(mode))
    return Response(dumps({"address": address}), status=200)
开发者ID:jacobyn,项目名称:lineseg-game,代码行数:28,代码来源:temp.py

示例2: qualify

# 需要导入模块: from psiturk.psiturk_config import PsiturkConfig [as 别名]
# 或者: from psiturk.psiturk_config.PsiturkConfig import get [as 别名]
def qualify(qualification, value, worker):
    """Assign a qualification to a worker."""
    # create connection to AWS
    from boto.mturk.connection import MTurkConnection
    config = PsiturkConfig()
    config.load_config()
    aws_access_key_id = config.get('AWS Access', 'aws_access_key_id')
    aws_secret_access_key = config.get('AWS Access', 'aws_secret_access_key')
    conn = MTurkConnection(aws_access_key_id, aws_secret_access_key)

    def get_workers_with_qualification(qualification):
        """Get workers with the given qualification."""
        results = []
        continue_flag = True
        page = 1
        while(continue_flag):
            new_results = conn.get_qualifications_for_qualification_type(
                qualification,
                page_size=100,
                page_number=page)

            if(len(new_results) == 0):
                continue_flag = False
            else:
                results.extend(new_results)
                page = page + 1

        return results

    results = get_workers_with_qualification(qualification)
    workers = [x.SubjectId for x in results]

    # assign the qualification
    click.echo(
        "Assigning qualification {} with value {} to worker {}".format(
            qualification,
            value,
            worker))

    if worker in workers:
        result = conn.update_qualification_score(qualification, worker, value)
    else:
        result = conn.assign_qualification(qualification, worker, value)

    if result:
        click.echo(result)

    # print out the current set of workers with the qualification
    results = get_workers_with_qualification(qualification)

    click.echo("{} workers with qualification {}:".format(
        len(results),
        qualification))

    values = [r.IntegerValue for r in results]
    unique_values = list(set([r.IntegerValue for r in results]))
    for v in unique_values:
        click.echo("{} with value {}".format(
            len([val for val in values if val == v]),
            v))
开发者ID:berkeley-cocosci,项目名称:Wallace,代码行数:62,代码来源:command_line.py

示例3: __init__

# 需要导入模块: from psiturk.psiturk_config import PsiturkConfig [as 别名]
# 或者: from psiturk.psiturk_config.PsiturkConfig import get [as 别名]
 def __init__(self):
     config = PsiturkConfig()
     config.load_config()
     self.access_key = config.get("psiTurk Access", "psiturk_access_key_id")
     self.secret_key = config.get("psiTurk Access", "psiturk_secret_access_id")
     self.local_port = config.getint("Server Parameters", "port")
     self.is_open = False
     self.tunnel_port = 8000  # Set by tunnel server
     self.tunnel_host = "tunnel.psiturk.org"
     self.tunnel_server = os.path.join(os.path.dirname(__file__), "tunnel/ngrok")
     self.tunnel_config = os.path.join(os.path.dirname(__file__), "tunnel/ngrok-config")
开发者ID:wyndwarrior,项目名称:psiTurk,代码行数:13,代码来源:psiturk_org_services.py

示例4: __init__

# 需要导入模块: from psiturk.psiturk_config import PsiturkConfig [as 别名]
# 或者: from psiturk.psiturk_config.PsiturkConfig import get [as 别名]
 def __init__(self, config=None):
     if not config:
         config = PsiturkConfig()
         config.load_config()
     self.access_key = config.get('psiTurk Access', 'psiturk_access_key_id')
     self.secret_key = config.get('psiTurk Access', 'psiturk_secret_access_id')
     self.local_port = config.getint('Server Parameters', 'port')
     self.is_open = False
     self.tunnel_port = 8000  # Set by tunnel server
     self.tunnel_host = 'tunnel.psiturk.org'
     self.tunnel_server = os.path.join(os.path.dirname(__file__),
                                       "tunnel/ngrok")
     self.tunnel_config = os.path.join(os.path.dirname(__file__),
                                       "tunnel/ngrok-config")
开发者ID:NYUCCL,项目名称:psiTurk,代码行数:16,代码来源:psiturk_org_services.py

示例5: awaken

# 需要导入模块: from psiturk.psiturk_config import PsiturkConfig [as 别名]
# 或者: from psiturk.psiturk_config.PsiturkConfig import get [as 别名]
def awaken(app, databaseurl):
    """Restore the database from a given url."""
    config = PsiturkConfig()
    config.load_config()

    database_size = config.get('Database Parameters', 'database_size')

    subprocess.call(
        "heroku addons:create heroku-postgresql:{} --app {}".format(
            database_size,
            app),
        shell=True)

    subprocess.call("heroku pg:wait --app {}".format(app), shell=True)

    conn = boto.connect_s3(
        config.get('AWS Access', 'aws_access_key_id'),
        config.get('AWS Access', 'aws_secret_access_key'),
    )

    bucket = conn.get_bucket(app)
    key = bucket.lookup('database.dump')
    url = key.generate_url(expires_in=300)

    cmd = "heroku pg:backups restore"
    subprocess.call(
        "{} '{}' DATABASE_URL --app {} --confirm {}".format(
            cmd,
            url,
            app,
            app),
        shell=True)

    subprocess.call(
        "heroku addons:create rediscloud:250 --app {}".format(app),
        shell=True)

    # Scale up the dynos.
    scale_up_dynos(app)
开发者ID:berkeley-cocosci,项目名称:Wallace,代码行数:41,代码来源:command_line.py

示例6: backup

# 需要导入模块: from psiturk.psiturk_config import PsiturkConfig [as 别名]
# 或者: from psiturk.psiturk_config.PsiturkConfig import get [as 别名]
def backup(app):
    """Dump the database."""
    dump_path = dump_database(app)

    config = PsiturkConfig()
    config.load_config()

    conn = boto.connect_s3(
        config.get('AWS Access', 'aws_access_key_id'),
        config.get('AWS Access', 'aws_secret_access_key'),
    )

    bucket = conn.create_bucket(
        app,
        location=boto.s3.connection.Location.DEFAULT
    )

    k = boto.s3.key.Key(bucket)
    k.key = 'database.dump'
    k.set_contents_from_filename(dump_path)
    url = k.generate_url(expires_in=0, query_auth=False)

    log("The database backup URL is...")
    print(url)
开发者ID:berkeley-cocosci,项目名称:Wallace,代码行数:26,代码来源:command_line.py

示例7: scale_up_dynos

# 需要导入模块: from psiturk.psiturk_config import PsiturkConfig [as 别名]
# 或者: from psiturk.psiturk_config.PsiturkConfig import get [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)
开发者ID:berkeley-cocosci,项目名称:Wallace,代码行数:26,代码来源:command_line.py

示例8: PsiTurkRecruiter

# 需要导入模块: from psiturk.psiturk_config import PsiturkConfig [as 别名]
# 或者: from psiturk.psiturk_config.PsiturkConfig import get [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)
#.........这里部分代码省略.........
开发者ID:sissiwxy,项目名称:Wallace,代码行数:103,代码来源:recruiters.py

示例9: configure_hit

# 需要导入模块: from psiturk.psiturk_config import PsiturkConfig [as 别名]
# 或者: from psiturk.psiturk_config.PsiturkConfig import get [as 别名]
    def configure_hit(self, hit_config):
        ''' Configure HIT '''
        # configure question_url based on the id
        experiment_portal_url = hit_config['ad_location']
        frame_height = 600
        mturk_question = ExternalQuestion(experiment_portal_url, frame_height)

        # Qualification:
        quals = Qualifications()
        approve_requirement = hit_config['approve_requirement']
        quals.add(
            PercentAssignmentsApprovedRequirement("GreaterThanOrEqualTo",
                                                  approve_requirement))

        if hit_config['us_only']:
            quals.add(LocaleRequirement("EqualTo", "US"))

        # Create a HIT type for this HIT.
        hit_type = self.mtc.register_hit_type(
            hit_config['title'],
            hit_config['description'],
            hit_config['reward'],
            hit_config['duration'],
            keywords=hit_config['keywords'],
            approval_delay=None,
            qual_req=None)[0]

        # Check the config file to see if notifications are wanted.
        config = PsiturkConfig()
        config.load_config()

        try:
            url = config.get('Server Parameters', 'notification_url')

            all_event_types = [
                "AssignmentAccepted",
                "AssignmentAbandoned",
                "AssignmentReturned",
                "AssignmentSubmitted",
                "HITReviewable",
                "HITExpired",
            ]

            self.mtc.set_rest_notification(
                hit_type.HITTypeId,
                url,
                event_types=all_event_types)

        except:
            pass

        # Specify all the HIT parameters
        self.param_dict = dict(
            hit_type=hit_type.HITTypeId,
            question=mturk_question,
            lifetime=hit_config['lifetime'],
            max_assignments=hit_config['max_assignments'],
            title=hit_config['title'],
            description=hit_config['description'],
            keywords=hit_config['keywords'],
            reward=hit_config['reward'],
            duration=hit_config['duration'],
            approval_delay=None,
            questions=None,
            qualifications=quals,
            response_groups=[
                'Minimal',
                'HITDetail',
                'HITQuestion',
                'HITAssignmentSummary'
            ])
开发者ID:PlasmaSheep,项目名称:psiTurk,代码行数:73,代码来源:amt_services.py

示例10: deploy_sandbox_shared_setup

# 需要导入模块: from psiturk.psiturk_config import PsiturkConfig [as 别名]
# 或者: from psiturk.psiturk_config.PsiturkConfig import get [as 别名]
def deploy_sandbox_shared_setup(verbose=True, 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(debug=False, verbose=verbose)

    # 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')

    # Set up postgres database and AWS/psiTurk environment variables.
    cmds = [
        "heroku addons:create heroku-postgresql:{}".format(database_size),

        "heroku pg:wait",

        "heroku addons:create redistogo:small",

        "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'),
    ]
    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")

    # Set the database URL in the config file to the newly generated one.
    log("Saving the URL of the postgres database...")
    db_url = subprocess.check_output(
        "heroku config:get DATABASE_URL --app " + id, shell=True)
    config.set("Database Parameters", "database_url", db_url.rstrip())
    subprocess.call("git add config.txt", stdout=OUT, shell=True),
    time.sleep(0.25)
    subprocess.call(
        'git commit -m "Save URLs for database and notifications"',
        stdout=OUT,
        shell=True)
    time.sleep(0.25)

    # Launch the Heroku app.
    log("Pushing code to Heroku...")
    subprocess.call("git push heroku HEAD:master", stdout=OUT,
                    stderr=OUT, shell=True)

    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')
#.........这里部分代码省略.........
开发者ID:sissiwxy,项目名称:Wallace,代码行数:103,代码来源:command_line.py

示例11: debug

# 需要导入模块: from psiturk.psiturk_config import PsiturkConfig [as 别名]
# 或者: from psiturk.psiturk_config.PsiturkConfig import get [as 别名]
def debug(verbose):
    """Run the experiment locally."""
    (id, tmp) = setup(debug=True, verbose=verbose)

    # Drop all the tables from the database.
    db.init_db(drop_all=True)

    # Switch to the temporary directory.
    cwd = os.getcwd()
    os.chdir(tmp)

    # Load psiTurk configuration.
    config = PsiturkConfig()
    config.load_config()

    # Set the mode to debug.
    config.set("Experiment Configuration", "mode", "debug")
    config.set("Shell Parameters", "launch_in_sandbox_mode", "true")
    config.set(
        "Server Parameters",
        "logfile",
        os.path.join(cwd, config.get("Server Parameters", "logfile")))

    # Swap in the HotAirRecruiter
    os.rename("wallace_experiment.py", "wallace_experiment_tmp.py")
    with open("wallace_experiment_tmp.py", "r+") as f:
        with open("wallace_experiment.py", "w+") as f2:
            f2.write("from wallace.recruiters import HotAirRecruiter\n")
            for idx, line in enumerate(f):
                if re.search("\s*self.recruiter = (.*)", line):
                    p = line.partition("self.recruiter =")
                    f2.write(p[0] + p[1] + ' HotAirRecruiter\n')
                else:
                    f2.write(line)

    os.remove("wallace_experiment_tmp.py")

    # Set environment variables.
    aws_vars = ['aws_access_key_id', 'aws_secret_access_key', 'aws_region']
    for var in aws_vars:
        if var not in os.environ:
            os.environ[var] = config.get('AWS Access', var)

    pt_vars = ['psiturk_access_key_id', 'psiturk_secret_access_id']
    for var in pt_vars:
        if var not in os.environ:
            os.environ[var] = config.get('psiTurk Access', var)

    if "HOST" not in os.environ:
        os.environ["HOST"] = config.get('Server Parameters', 'host')

    # Start up the local server
    log("Starting up the server...")

    # Try opening the psiTurk shell.
    try:
        p = pexpect.spawn("psiturk")
        p.expect_exact("]$")
        p.sendline("server on")
        p.expect_exact("Experiment server launching...")

        # Launche the experiment.
        time.sleep(4)

        host = config.get("Server Parameters", "host")
        port = config.get("Server Parameters", "port")

        subprocess.call(
            'curl --data "" http://{}:{}/launch'.format(host, port),
            shell=True)

        log("Here's the psiTurk shell...")
        p.interact()

    except Exception:
        print "\nCouldn't open the psiTurk shell. Internet connection okay?"

    log("Completed debugging of experiment " + id + ".")
    os.chdir(cwd)
开发者ID:sissiwxy,项目名称:Wallace,代码行数:81,代码来源:command_line.py

示例12: str

# 需要导入模块: from psiturk.psiturk_config import PsiturkConfig [as 别名]
# 或者: from psiturk.psiturk_config.PsiturkConfig import get [as 别名]
            "Fix the errors and then try running 'wallace verify'.")

    # Verify that the Postgres server is running.
    try:
        psycopg2.connect(database="x", user="postgres", password="nada")
    except psycopg2.OperationalError, e:
        if "could not connect to server" in str(e):
            raise RuntimeError("The Postgres server isn't running.")

    # Load psiTurk configuration.
    config = PsiturkConfig()
    config.load_config()

    # Check that the version of Wallace specified in the config file is the one
    # that we are currently running.
    wallace_version = config.get('Experiment Configuration', 'wallace_version')
    this_version = pkg_resources.require("wallace")[0].version
    if wallace_version != this_version:
        raise AssertionError(
            "You are using Wallace v" + this_version + ", "
            "but the experiment requires v" + wallace_version)

    # Generate a unique id for this experiment.
    id = "w" + str(uuid.uuid4())[0:28]
    log("Running as experiment " + id + "...")

    # Copy this directory into a temporary folder, ignoring .git
    dst = os.path.join(tempfile.mkdtemp(), id)
    to_ignore = shutil.ignore_patterns(
        ".git/*",
        "*.db",
开发者ID:sissiwxy,项目名称:Wallace,代码行数:33,代码来源:command_line.py

示例13: configure_hit

# 需要导入模块: from psiturk.psiturk_config import PsiturkConfig [as 别名]
# 或者: from psiturk.psiturk_config.PsiturkConfig import get [as 别名]
    def configure_hit(self, hit_config):
        ''' Configure HIT '''

        # Qualification:
        quals = []
        quals.append(dict(
            QualificationTypeId=PERCENT_ASSIGNMENTS_APPROVED_QUAL_ID,
            Comparator='GreaterThanOrEqualTo',
            IntegerValues=[int(hit_config['approve_requirement'])]
        ))

        quals.append(dict(
            QualificationTypeId=NUMBER_HITS_APPROVED_QUAL_ID,
            Comparator='GreaterThanOrEqualTo',
            IntegerValues=[int(hit_config['number_hits_approved'])]
        ))

        if hit_config['require_master_workers']:
            master_qualId = MASTERS_SANDBOX_QUAL_ID if self.is_sandbox else MASTERS_QUAL_ID
            quals.append(dict(
                QualificationTypeId=master_qualId,
                Comparator='Exists'
            ))

        if hit_config['us_only']:
            quals.append(dict(
                QualificationTypeId=LOCALE_QUAL_ID,
                Comparator='EqualTo',
                LocaleValues=[{'Country': 'US'}]
            ))

        # Create a HIT type for this HIT.
        hit_type = self.mtc.create_hit_type(
            Title=hit_config['title'],
            Description=hit_config['description'],
            Reward=str(hit_config['reward']),
            AssignmentDurationInSeconds=int(hit_config['duration'].total_seconds()),
            Keywords=hit_config['keywords'],
            QualificationRequirements=quals)

        # Check the config file to see if notifications are wanted.
        config = PsiturkConfig()
        config.load_config()

        try:
            url = config.get('Server Parameters', 'notification_url')

            all_event_types = [
                "AssignmentAccepted",
                "AssignmentAbandoned",
                "AssignmentReturned",
                "AssignmentSubmitted",
                "HITReviewable",
                "HITExpired",
            ]

            # TODO: not sure if this works. Can't find documentation in PsiTurk or MTurk
            self.mtc.update_notification_settings(
                HitTypeId=hit_type['HITTypeId'],
                Notification=dict(
                    Destination=url,
                    Transport='REST',
                    Version=NOTIFICATION_VERSION,
                    EventTypes=all_event_types,
                ),
            )

        except Exception as e:
            pass

        schema_url = "http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2006-07-14/ExternalQuestion.xsd"
        template = '<ExternalQuestion xmlns="%(schema_url)s"><ExternalURL>%%(external_url)s</ExternalURL><FrameHeight>%%(frame_height)s</FrameHeight></ExternalQuestion>' % vars()
        question = template % dict(
            external_url=hit_config['ad_location'],
            frame_height=600,
        )


        # Specify all the HIT parameters
        self.param_dict = dict(
            HITTypeId=hit_type['HITTypeId'],
            Question=question,
            LifetimeInSeconds=int(hit_config['lifetime'].total_seconds()),
            MaxAssignments=hit_config['max_assignments'],
            # TODO
            # ResponseGroups=[
            #     'Minimal',
            #     'HITDetail',
            #     'HITQuestion',
            #     'HITAssignmentSummary'
            # ]
            )
开发者ID:NYUCCL,项目名称:psiTurk,代码行数:94,代码来源:amt_services.py

示例14: PsiturkConfig

# 需要导入模块: from psiturk.psiturk_config import PsiturkConfig [as 别名]
# 或者: from psiturk.psiturk_config.PsiturkConfig import get [as 别名]
from psiturk.models import Participant
from json import dumps, loads

# 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
开发者ID:JSlote,项目名称:cswro-exp-1,代码行数:33,代码来源:custom.py


注:本文中的psiturk.psiturk_config.PsiturkConfig.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。