From: "Aníbal Limón" <anibal.limon@linux.intel.com>
To: yocto@yoctoproject.org
Cc: belen.barros.pena@linux.intel.com
Subject: [[PATCH][error-report-web] 6/8] Post/{models, parser}.py: Add support for receive/store error_type.
Date: Mon, 13 Jun 2016 18:32:14 -0500 [thread overview]
Message-ID: <1465860736-26581-7-git-send-email-anibal.limon@linux.intel.com> (raw)
In-Reply-To: <1465860736-26581-1-git-send-email-anibal.limon@linux.intel.com>
For compatibility reasons if error_type isn't specified in the JSON
payload use BuildErrorType.RECIPE by default.
[YOCTO #7584]
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
---
Post/models.py | 10 ++++++++++
Post/parser.py | 11 +++++++++--
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/Post/models.py b/Post/models.py
index f8d9916..bec2abd 100644
--- a/Post/models.py
+++ b/Post/models.py
@@ -17,6 +17,16 @@ class BuildErrorType(object):
BITBAKE_SELFTEST = "Bitbake selftest"
OE_SELFTEST = "OE selftest"
+ @staticmethod
+ def is_supported(error_type):
+ if error_type == BuildErrorType.RECIPE or \
+ error_type == BuildErrorType.BITBAKE_CORE or \
+ error_type == BuildErrorType.BITBAKE_SELFTEST or \
+ error_type == BuildErrorType.OE_SELFTEST:
+ return True
+
+ return False
+
# Create your models here.
class Build(models.Model):
DATE = models.DateTimeField('Submit date', blank=True, null=True)
diff --git a/Post/parser.py b/Post/parser.py
index 599afde..295870f 100644
--- a/Post/parser.py
+++ b/Post/parser.py
@@ -8,7 +8,7 @@
# Licensed under the MIT license, see COPYING.MIT for details
import json, re
-from Post.models import Build, BuildFailure
+from Post.models import Build, BuildFailure, BuildErrorType
from django.conf import settings
from django.utils import timezone
from django.core.urlresolvers import reverse
@@ -40,6 +40,7 @@ class Parser:
if self.contains_tags(jsondata) == True:
return { 'error' : 'Invalid characters in json' }
+ error_desc = ""
b = Build.objects.create()
try:
b.MACHINE = str(jsondata['machine'])
@@ -53,6 +54,12 @@ class Parser:
b.EMAIL = str(jsondata['email'])
b.LINK_BACK = jsondata.get("link_back", None)
+ error_type = jsondata.get("error_type", None) or BuildErrorType.RECIPE
+ if not BuildErrorType.is_supported(error_type):
+ error_desc = "Unsupported error_type %s" % error_type
+ raise ""
+ b.ERROR_TYPE = error_type
+
# Extract the branch and commit
g = re.match(r'(.*): (.*)', jsondata['branch_commit'])
@@ -68,7 +75,7 @@ class Parser:
b.save()
failures = jsondata['failures']
except:
- return { 'error' : "Problem reading json payload" }
+ return { 'error' : "Problem reading json payload, %s" % error_desc }
for fail in failures:
if len(fail) > int(settings.MAX_UPLOAD_SIZE):
--
2.1.4
next prev parent reply other threads:[~2016-06-13 23:31 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-13 23:32 [[PATCH][error-report-web] 0/8] Allow other type of errors and django 1.8 Aníbal Limón
2016-06-13 23:32 ` [[PATCH][error-report-web] 1/8] requirements.txt: Update requeriments for use 1.8 LTS Django version Aníbal Limón
2016-06-13 23:32 ` [[PATCH][error-report-web] 2/8] urls.py: RedirectView, fix warnings about change of default value in django 1.9 Aníbal Limón
2016-06-13 23:32 ` [[PATCH][error-report-web] 3/8] Post/models.py: Increase the TASK field length Aníbal Limón
2016-06-13 23:32 ` [[PATCH][error-report-web] 4/8] Post/migrations/0003_auto_20150603_0913.py: Replace tabs for spaces Aníbal Limón
2016-06-13 23:32 ` [[PATCH][error-report-web] 5/8] Post/models.py: Build model add support for Error type Aníbal Limón
2016-06-14 13:30 ` Michael Wood
2016-06-14 16:44 ` Aníbal Limón
2016-06-14 19:23 ` Aníbal Limón
2016-06-13 23:32 ` Aníbal Limón [this message]
2016-06-13 23:32 ` [[PATCH][error-report-web] 7/8] views/templates: Add support for display different type of errors Aníbal Limón
2016-06-13 23:32 ` [[PATCH][error-report-web] 8/8] Post/{models, views}.py: Add FAILURE field on BuildFailure model Aníbal Limón
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1465860736-26581-7-git-send-email-anibal.limon@linux.intel.com \
--to=anibal.limon@linux.intel.com \
--cc=belen.barros.pena@linux.intel.com \
--cc=yocto@yoctoproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.