3
from _init_environment import SetHostMTurkConnection
5
def description_filter(substring):
6
return lambda hit: substring in hit.Title
9
return conn.disable_hit(hit.HITId)
12
# assignments must be first approved or rejected
13
for assignment in conn.get_assignments(hit.HITId):
14
if assignment.AssignmentStatus == 'Submitted':
15
conn.approve_assignment(assignment.AssignmentId)
16
return conn.dispose_hit(hit.HITId)
19
"""Remove any boto test related HIT's"""
23
conn = SetHostMTurkConnection()
26
is_boto = description_filter('Boto')
27
print 'getting hits...'
28
all_hits = list(conn.get_all_hits())
29
is_reviewable = lambda hit: hit.HITStatus == 'Reviewable'
30
is_not_reviewable = lambda hit: not is_reviewable(hit)
31
hits_to_process = filter(is_boto, all_hits)
32
hits_to_disable = filter(is_not_reviewable, hits_to_process)
33
hits_to_dispose = filter(is_reviewable, hits_to_process)
34
print 'disabling/disposing %d/%d hits' % (len(hits_to_disable), len(hits_to_dispose))
35
map(disable_hit, hits_to_disable)
36
map(dispose_hit, hits_to_dispose)
38
total_hits = len(all_hits)
39
hits_processed = len(hits_to_process)
40
skipped = total_hits - hits_processed
41
fmt = 'Processed: %(total_hits)d HITs, disabled/disposed: %(hits_processed)d, skipped: %(skipped)d'
44
if __name__ == '__main__':