Code Duplication    Length = 19-23 lines in 3 locations

django-data/image/submissions/tasks.py 1 location

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

django-data/image/animals/tasks.py 1 location

@@ 30-48 (lines=19) @@
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
        # get submission object
34
        submission_obj = Submission.objects.get(pk=args[0])
35
36
        # mark submission with ERROR
37
        submission_obj.status = ERROR
38
        submission_obj.message = ("Error in batch delete for animals: %s"
39
                                  % (str(exc)))
40
        submission_obj.save()
41
42
        send_message(submission_obj)
43
44
        # send a mail to the user with the stacktrace (einfo)
45
        submission_obj.owner.email_user(
46
            "Error in batch delete for animals: %s" % (args[0]),
47
            ("Something goes wrong in batch delete for animals. Please report "
48
             "this to InjectTool team\n\n %s" % str(einfo)),
49
        )
50
51
        # TODO: submit mail to admin

django-data/image/samples/tasks.py 1 location

@@ 30-48 (lines=19) @@
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
        # get submission object
34
        submission_obj = Submission.objects.get(pk=args[0])
35
36
        # mark submission with ERROR
37
        submission_obj.status = ERROR
38
        submission_obj.message = ("Error in batch delete for samples: %s"
39
                                  % (str(exc)))
40
        submission_obj.save()
41
42
        send_message(submission_obj)
43
44
        # send a mail to the user with the stacktrace (einfo)
45
        submission_obj.owner.email_user(
46
            "Error in batch delete for samples: %s" % (args[0]),
47
            ("Something goes wrong in batch delete for samples. Please report "
48
             "this to InjectTool team\n\n %s" % str(einfo)),
49
        )
50
51
        # TODO: submit mail to admin