def configure_qualifications_task(): if settings.MTURK_SANDBOX: return from common.utils import import_modules modules = import_modules(settings.MTURK_MODULES) for m in modules: if hasattr(m, 'configure_qualifications'): print 'Configuring qualifications: %s' % m.__name__ m.configure_qualifications()
def configure_all_experiments(show_progress=False): """ Configure all experiments by searching for modules of the form '<app>.experiments' (where "app" is an installed app). The method configure_experiment() is then invoked for each such module found. """ from mturk.models import Experiment with transaction.atomic(): # turn off all experiments unless turned on by configure_experiments for exp in Experiment.objects.all(): if exp.new_hit_settings: exp.new_hit_settings.auto_add_hits = False exp.new_hit_settings.save() from common.utils import import_modules modules = import_modules(settings.MTURK_MODULES) for mt in modules: if show_progress: print ' Running %s.configure_experiments()' % mt.__name__ mt.configure_experiments()
def configure_all_experiments(show_progress=False): """ Configure all experiments by searching for modules of the form '<app>.experiments' (where "app" is an installed app). The method configure_experiment() is then invoked for each such module found. """ from mturk.models import Experiment with transaction.atomic(): # turn off all experiments unless turned on by configure_experiments for exp in Experiment.objects.all(): if exp.new_hit_settings: exp.new_hit_settings.auto_add_hits = False exp.new_hit_settings.save() from common.utils import import_modules modules = import_modules(settings.MTURK_MODULES) for mt in modules: if show_progress: print ' Running %s.configure_experiments()' % mt.__name__ mt.configure_experiments()
def mturk_update_votes_cubam_task(show_progress=False): # use a lock directory to ensure only one thread is running LOCK_DIR = '.mturk_update_votes_cubam_task' try: os.mkdir(LOCK_DIR) except: print ("Already running! If you are *sure* that " + "mturk_update_votes_cubam_task is not running, " + "delete the .mturk_update_votes_cubam_task directory") return try: from common.utils import import_modules modules = import_modules(settings.MTURK_MODULES) for mt1 in modules: if not hasattr(mt1, 'update_votes_cubam'): continue print '\nStarting: %s.update_votes_cubam()' % mt1.__name__ changed_objects = mt1.update_votes_cubam( show_progress=show_progress) if changed_objects: # update pending contents add_pending_objects_task.delay( [get_content_tuple(c) for c in changed_objects]) # other updates for mt2 in modules: if hasattr(mt2, 'update_changed_objects'): mt2.update_changed_objects(changed_objects) print '\nDone: %s.update_votes_cubam()' % mt1.__name__ finally: os.rmdir(LOCK_DIR)