1
from boto.mturk.connection import MTurkConnection
4
"""Remove any boto test related HIT's"""
6
conn = MTurkConnection(host='mechanicalturk.sandbox.amazonaws.com')
13
# reset the total for this loop
16
# search all the hits in the sandbox
17
search_rs = conn.search_hits(page_size=page_size, page_number=current_page)
22
# delete any with Boto in the description
23
print 'hit id:%s Status:%s, desc:%s' %(hit.HITId, hit.HITStatus, hit.Description)
24
if hit.Description.find('Boto') != -1:
25
if hit.HITStatus != 'Reviewable':
26
print 'Disabling hit id:%s %s' %(hit.HITId, hit.Description)
27
disable_rs = conn.disable_hit(hit.HITId)
30
# update the running total
33
print 'Error when disabling, code:%s, message:%s' %(disable_rs.Code, disable_rs.Message)
35
print 'Disposing hit id:%s %s' %(hit.HITId, hit.Description)
36
dispose_rs = conn.dispose_hit(hit.HITId)
39
# update the running total
42
print 'Error when disposing, code:%s, message:%s' %(dispose_rs.Code, dispose_rs.Message)
45
if hit.HITId not in ignored:
46
print 'ignored:%s' %hit.HITId
47
ignored.append(hit.HITId)
50
if int(search_rs.TotalNumResults) > current_page*page_size:
51
# if we have disabled any HITs on this page
52
# then we don't need to go to a new page
54
if not disabled_count:
60
print 'Error performing search, code:%s, message:%s' %(search_rs.Code, search_rs.Message)
63
total_ignored = len(ignored)
64
print 'Processed: %d HITs, disabled/disposed: %d, ignored: %d' %(total_ignored + total_disabled, total_disabled, total_ignored)
66
if __name__ == '__main__':