def revert_file(request, runjob_id): if request.method == 'POST': runjob = get_object_or_404(RunJob, pk=runjob_id) print backup_mei_path(runjob) print os.path.exists(backup_mei_path(runjob)) if os.path.exists(backup_mei_path(runjob)): shutil.copy(backup_mei_path(runjob), live_mei_path(runjob)) else: raise Http404
def run_task(self, result_id, runjob_id, *args, **kwargs): runjob = RunJob.objects.get(pk=runjob_id) if runjob.needs_input: if runjob.status == RunJobStatus.RUN_ONCE_WAITING: self.retry(args=[result_id, runjob_id], *args, countdown=10, **kwargs) else: # This is the first time the job is running. taskutil.set_running(runjob) page_path = runjob.page.compat_file_path self._create_temp_neon_directory(runjob) mei_path = taskutil.get_input_path(runjob, result_id) shutil.copy(mei_path, live_mei_path(runjob)) shutil.copy(live_mei_path(runjob), backup_mei_path(runjob)) page_image = Image.open(page_path) page_image.save(compressed_image_path(runjob), quality=40) taskutil.set_run_once_waiting(runjob) self.retry(args=[result_id, runjob_id], *args, countdown=10, **kwargs) else: taskutil.set_running(runjob) result = taskutil.init_result(runjob) taskutil.save_result(result, live_mei_path(runjob)) return str(result.uuid)