| @@ 30-56 (lines=27) @@ | ||
| 27 | # Ovverride default on failure method |
|
| 28 | # This is not a failed validation for a wrong value, this is an |
|
| 29 | # error in task that mean an error in coding |
|
| 30 | def on_failure(self, exc, task_id, args, kwargs, einfo): |
|
| 31 | logger.error('{0!r} failed: {1!r}'.format(task_id, exc)) |
|
| 32 | ||
| 33 | submission_id, sample_ids = args[0], args[1] |
|
| 34 | ||
| 35 | logger.error( |
|
| 36 | ("BatchDeleteAnimals called with submission_id: %s and " |
|
| 37 | "sample_ids: %s" % (submission_id, sample_ids)) |
|
| 38 | ) |
|
| 39 | ||
| 40 | # get submission object |
|
| 41 | submission_obj = Submission.objects.get(pk=submission_id) |
|
| 42 | ||
| 43 | # mark submission with ERROR |
|
| 44 | submission_obj.status = ERROR |
|
| 45 | submission_obj.message = ( |
|
| 46 | "Error in sample batch delete: %s" % (str(exc))) |
|
| 47 | submission_obj.save() |
|
| 48 | ||
| 49 | send_message(submission_obj) |
|
| 50 | ||
| 51 | # send a mail to the user with the stacktrace (einfo) |
|
| 52 | submission_obj.owner.email_user( |
|
| 53 | "Error in sample batch delete for submission: %s" % ( |
|
| 54 | submission_obj.id), |
|
| 55 | ("Something goes wrong in batch delete for samples. Please report " |
|
| 56 | "this to InjectTool team\n\n %s" % str(einfo)), |
|
| 57 | ) |
|
| 58 | ||
| 59 | # TODO: submit mail to admin |
|
| @@ 30-56 (lines=27) @@ | ||
| 27 | # Ovverride default on failure method |
|
| 28 | # This is not a failed validation for a wrong value, this is an |
|
| 29 | # error in task that mean an error in coding |
|
| 30 | def on_failure(self, exc, task_id, args, kwargs, einfo): |
|
| 31 | logger.error('{0!r} failed: {1!r}'.format(task_id, exc)) |
|
| 32 | ||
| 33 | submission_id, animal_ids = args[0], args[1] |
|
| 34 | ||
| 35 | logger.error( |
|
| 36 | ("BatchDeleteAnimals called with submission_id: %s and " |
|
| 37 | "animal_ids: %s" % (submission_id, animal_ids)) |
|
| 38 | ) |
|
| 39 | ||
| 40 | # get submission object |
|
| 41 | submission_obj = Submission.objects.get(pk=submission_id) |
|
| 42 | ||
| 43 | # mark submission with ERROR |
|
| 44 | submission_obj.status = ERROR |
|
| 45 | submission_obj.message = ( |
|
| 46 | "Error in animal batch delete: %s" % (str(exc))) |
|
| 47 | submission_obj.save() |
|
| 48 | ||
| 49 | send_message(submission_obj) |
|
| 50 | ||
| 51 | # send a mail to the user with the stacktrace (einfo) |
|
| 52 | submission_obj.owner.email_user( |
|
| 53 | "Error in animal batch delete for submission: %s" % ( |
|
| 54 | submission_obj.id), |
|
| 55 | ("Something goes wrong in batch delete for animals. Please report " |
|
| 56 | "this to InjectTool team\n\n %s" % str(einfo)), |
|
| 57 | ) |
|
| 58 | ||
| 59 | # TODO: submit mail to admin |
|