def load(self): if self.sandbox: print "Using SANDBOX ..." self.mtc = boto.connect_mturk(host=MTurkWrapper.SANDBOX) else: print "Using REAL MTURK!" self.mtc = boto.connect_mturk()
def connect(self): """Set up connection to the Amazon MTurk server""" # Sandbox connection if self.sandbox: host = "mechanicalturk.sandbox.amazonaws.com" # Real MTurk connection else: host = "mechanicalturk.amazonaws.com" try: self.connection = boto.connect_mturk(host=host) return True except: return False
def get_mturk_connection(sandbox): """Fetches the sandbox or regular mturk connection.""" if sandbox: host = 'mechanicalturk.sandbox.amazonaws.com' else: host = 'mechanicalturk.amazonaws.com' connection = boto.connect_mturk( aws_access_key_id=current_app.config['MTURK_ACCESS_KEY_ID'], aws_secret_access_key=current_app.config['MTURK_SECRET_ACCESS_KEY'], host=host, ) return connection
def make2(): import boto mt = boto.connect_mturk( AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) return mt
from django.shortcuts import render, redirect, render_to_response from django.http import HttpResponse from django.template.loader import render_to_string from django.template.context import Context from GraphSearchApp.models import UserProfile, Photo # turk related stuff. import os import boto key = os.environ['AWS_ACCESS_KEY_ID'] secret = os.environ['AWS_SECRET_ACCESS_KEY'] conn = boto.connect_mturk(key, secret, host='mechanicalturk.sandbox.amazonaws.com') def make_hit(url, query): html = render_to_string('turkerview.html', Context({'description':query,'img_src':url})); question = boto.mturk.question.HTMLQuestion(html, 800) return conn.create_hit(question=question, title="Determine if an employer would disqualify a candidate based on an image", reward=0.01) def login(request): return render(request,'login.html') def process_photos(user): fb = user.get_offline_graph() photos = fb.get('me/photos') for photo in photos['data']: make_hit(photo['source'], "who is dumb") photo_db = Photo(profile=user.userprofile,fb_id=photo['id'],src=photo['source']) print photo['from']['id'] if photo['from']['id'] == user.facebook_id:
import boto import boto.mturk.qualification import os kw = {} #kw = {'host': 'mechanicalturk.sandbox.amazonaws.com'} # Uncomment for sandbox mtc = boto.connect_mturk(os.environ['AWS_ACCESS_KEY_ID'], os.environ['AWS_SECRET_ACCESS_KEY'], **kw) question = boto.mturk.question.ExternalQuestion('http://api.dappervision.com:8001', 1500) qualifications = boto.mturk.qualification.Qualifications() qualifications.add(boto.mturk.qualification.PercentAssignmentsApprovedRequirement('GreaterThan', 80, True)) qualifications.add(boto.mturk.qualification.NumberHitsApprovedRequirement('GreaterThan', 100, True)) out = mtc.create_hit(question=question, max_assignments=20, qualifications=qualifications, title='Do not attempt, No Reward oyGXb8ynEkNMLic', description='Do not attempt, no reward oyGXb8ynEkNMLic', keywords='dummy'.split(), duration=int(60 * 30), reward=0.0)