From: Mauro Carvalho Chehab Date: Sat, 28 Nov 2015 12:14:46 +0000 (-0200) Subject: parsemail: Generate useful retcodes X-Git-Tag: v1.1.0~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cbe992d84fba57831d44afb3a21cdf83454018b2;p=thirdparty%2Fpatchwork.git parsemail: Generate useful retcodes 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 Signed-off-by: Stephen Finucane --- diff --git a/patchwork/bin/parsemail.py b/patchwork/bin/parsemail.py index db948ea4..d93c623b 100755 --- a/patchwork/bin/parsemail.py +++ b/patchwork/bin/parsemail.py @@ -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 diff --git a/patchwork/bin/parsemail.sh b/patchwork/bin/parsemail.sh index 9973392d..c8220a79 100755 --- a/patchwork/bin/parsemail.sh +++ b/patchwork/bin/parsemail.sh @@ -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 $@