def verify_aws():
    """
    Verifies current aws login keys are valid
    """
    services = MTurkServices(config)
    key_id = request.json['aws_access_key_id']
    secret_key = request.json['aws_secret_access_key']
    is_valid = services.verify_aws_login(key_id, secret_key)
    return jsonify(aws_accnt=is_valid)
def verify_aws():
    """
    Verifies current aws login keys are valid
    """
    services = MTurkServices(config)
    key_id = request.json['aws_access_key_id']
    secret_key = request.json['aws_secret_access_key']
    is_valid = services.verify_aws_login(key_id, secret_key)
    return jsonify(aws_accnt=is_valid)
def at_a_glance_model():
    """
    Sync for dashboard at-a-glance pane.
    """
    services = MTurkServices(config)

    if request.method == 'GET':
        summary = services.get_summary()
        if summary:
            return summary
        else:
            return jsonify(error="unable to access aws")
def at_a_glance_model():
    """
    Sync for dashboard at-a-glance pane.
    """
    services = MTurkServices(config)

    if request.method == 'GET':
        summary = services.get_summary()
        if summary:
            return summary
        else:
            return jsonify(error="unable to access aws")
def approve_worker():
    CREDITED = 5
    if "assignmentId" in request.json:
        assignment_id = request.json["assignmentId"]
        services = MTurkServices(config)
        services.reject_worker(assignment_id)
        try:
            part = Participant.query.\
                      filter(Participant.assignmentid == assignment_id).one()
            part.status = CREDITED
            db_session.add(part)
            db_session.commit()
        except:
            print "Error: Database failed to credit participant"
        return ("Worker approved")
    return ("Error: Missing assignment id")
Beispiel #6
0
 def amt_services(self):
     if not self._cached_amt_services:
         self._cached_amt_services = MTurkServices(
             self.config.get('AWS Access', 'aws_access_key_id'), \
             self.config.get('AWS Access', 'aws_secret_access_key'),
             self.config.getboolean('Shell Parameters', 'launch_in_sandbox_mode'))
     return self._cached_amt_services
def approve_worker():
      CREDITED = 5
      if "assignmentId" in request.json:
          assignment_id = request.json["assignmentId"]
          services = MTurkServices(config)
          services.reject_worker(assignment_id)
          try:
              part = Participant.query.\
                        filter(Participant.assignmentid == assignment_id).one()
              part.status = CREDITED
              db_session.add(part)
              db_session.commit()
          except:
              print "Error: Database failed to credit participant"
          return("Worker approved")
      return("Error: Missing assignment id")
Beispiel #8
0
 def amt_services(self):
     if not self._cached_amt_services:
         self._cached_amt_services = MTurkServices(
             self.config.get('AWS Access', 'aws_access_key_id'), \
             self.config.get('AWS Access', 'aws_secret_access_key'),
             self.sandbox)
     return self._cached_amt_services
def turk_services():
    """
    """
    services = MTurkServices(config)
    mturk_request = request.json
    if "mturk_request" in request.json:
        if request.json["mturk_request"] == "create_hit":
            services.create_hit()
            return jsonify(msg="hit created")
        elif request.json["mturk_request"] == "expire_hit":
            hitid = request.json["hitid"]
            services.expire_hit(hitid)
            return jsonify(msg="hit expired")
        elif request.json["mturk_request"] == "extend_hit":
            hitid = request.json["hitid"]
            assignments_increment = request.json["assignments_increment"]
            expiration_increment = request.json["expiration_increment"]
            services.extend_hit(hitid, assignments_increment,
                                expiration_increment)
            return jsonify(msg="hit expired")
    return jsonify(error="psiTurk failed to recognize your request.")
def turk_services():
    """
    """
    services = MTurkServices(config)
    mturk_request = request.json
    if "mturk_request" in request.json:
        if request.json["mturk_request"] == "create_hit":
            services.create_hit()
            return jsonify(msg="hit created")
        elif request.json["mturk_request"] == "expire_hit":
            hitid = request.json["hitid"]
            services.expire_hit(hitid)
            return jsonify(msg="hit expired")
        elif request.json["mturk_request"] == "extend_hit":
           hitid = request.json["hitid"]
           assignments_increment = request.json["assignments_increment"]
           expiration_increment = request.json["expiration_increment"]
           services.extend_hit(hitid, assignments_increment, expiration_increment)
           return jsonify(msg="hit expired")
    return jsonify(error="psiTurk failed to recognize your request.")
def reject_worker():
      if "assignmentId" in request.json:
          services = MTurkServices(config)
          services.reject_worker(request.json["assignmentId"])
          return("Worker rejected")
      return("Error: Missing assignment id")
def get_workers():
    """
    provides an jsonified collection of workers pending review
    """
    services = MTurkServices(config)
    return jsonify(workers=services.get_workers())
def get_hits():
    """
    provides an jsonified collection of active hits
    """
    services = MTurkServices(config)
    return jsonify(hits=services.get_active_hits())
def get_hits():
    """
    provides an jsonified collection of active hits
    """
    services = MTurkServices(config)
    return jsonify(hits=services.get_active_hits())
Beispiel #15
0
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
def reject_worker():
    if "assignmentId" in request.json:
        services = MTurkServices(config)
        services.reject_worker(request.json["assignmentId"])
        return ("Worker rejected")
    return ("Error: Missing assignment id")
def get_workers():
    """
    provides an jsonified collection of workers pending review
    """
    services = MTurkServices(config)
    return jsonify(workers=services.get_workers())