]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
parsemail: Generate useful retcodes
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>
Sat, 28 Nov 2015 12:14:46 +0000 (10:14 -0200)
committerStephen Finucane <stephen.finucane@intel.com>
Tue, 19 Jan 2016 21:22:29 +0000 (21:22 +0000)
When things are broken at parsemail, we need to be able to
debug it. So, add some messages to it, in order to allow
checking what it actually did, and to let it return 1 if
an email got skipped by parsemail.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
patchwork/bin/parsemail.py
patchwork/bin/parsemail.sh

index db948ea4a9769caf8767256ed2c21f19bcc8b5f8..d93c623bcb21da70b516f2785b0f26efaa372945 100755 (executable)
@@ -439,15 +439,15 @@ def parse_mail(mail, list_id=None):
     # some basic sanity checks
     if 'From' not in mail:
         LOGGER.debug("Ignoring patch due to missing 'From'")
-        return 0
+        return 1
 
     if 'Subject' not in mail:
         LOGGER.debug("Ignoring patch due to missing 'Subject'")
-        return 0
+        return 1
 
     if 'Message-Id' not in mail:
         LOGGER.debug("Ignoring patch due to missing 'Message-Id'")
-        return 0
+        return 1
 
     hint = mail.get('X-Patchwork-Hint', '').lower()
     if hint == 'ignore':
@@ -461,7 +461,7 @@ def parse_mail(mail, list_id=None):
 
     if project is None:
         LOGGER.error('Failed to find a project for patch')
-        return 0
+        return 1
 
     msgid = mail.get('Message-Id').strip()
 
@@ -485,6 +485,7 @@ def parse_mail(mail, list_id=None):
         patch.delegate = get_delegate(
             mail.get('X-Patchwork-Delegate', '').strip())
         patch.save()
+        LOGGER.debug('Patch saved')
 
     if comment:
         if save_required:
@@ -495,6 +496,7 @@ def parse_mail(mail, list_id=None):
         comment.submitter = author
         comment.msgid = msgid
         comment.save()
+        LOGGER.debug('Comment saved')
 
     return 0
 
index 9973392de9d477db6d7cbe65d02bc2303084ed3f..c8220a799bbade9e949c6637d5759e2a8668c9fb 100755 (executable)
@@ -26,4 +26,4 @@ PYTHONPATH="$PATCHWORK_BASE":"$PATCHWORK_BASE/lib/python:$PYTHONPATH" \
         DJANGO_SETTINGS_MODULE=patchwork.settings.production \
         "$PATCHWORK_BASE/patchwork/bin/parsemail.py"
 
-exit 0
+exit $@