aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2015-03-02 19:37:47 +0000
committerMichael Wood <michael.g.wood@intel.com>2015-03-02 19:37:47 +0000
commit92fc9f5de3241eefb8a95883f80980d9d9a21d16 (patch)
tree839e916160234c156f31499d3a1db960efb71e47
parent9112ecd6cca1c2364ed2ce51fc85a20fccbd5ddf (diff)
downloaderror-report-web-92fc9f5de3241eefb8a95883f80980d9d9a21d16.tar.gz
error-report-web-92fc9f5de3241eefb8a95883f80980d9d9a21d16.tar.bz2
error-report-web-92fc9f5de3241eefb8a95883f80980d9d9a21d16.zip
parser: Add fall back for regex based parsing
Currently the branch, commit, recipe and recipe_version rely on being in a particular format so that they can be extracted by a regex. If this fails we should fall back and mark these fields just as "unknown" Signed-off-by: Michael Wood <michael.g.wood@intel.com>
-rw-r--r--Post/parser.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/Post/parser.py b/Post/parser.py
index 7311649..b293293 100644
--- a/Post/parser.py
+++ b/Post/parser.py
@@ -53,9 +53,16 @@ class Parser:
b.EMAIL = str(jsondata['email'])
b.LINK_BACK = jsondata.get("link_back", None)
+ # Extract the branch and commit
g = re.match(r'(.*): (.*)', jsondata['branch_commit'])
- b.BRANCH = str(g.group(1))
- b.COMMIT = str(g.group(2))
+
+ if g and g.lastindex == 2:
+ b.BRANCH = g.group(1)
+ b.COMMIT = g.group(2)
+ else:
+ b.BRANCH = "unknown"
+ b.COMMIT = "unknown"
+
b.DATE = timezone.now()
b.save()
@@ -67,9 +74,18 @@ class Parser:
if len(fail) > int(settings.MAX_UPLOAD_SIZE):
build_fails_logged.append({ 'id': -1, 'error' : "The size of the upload is too large" })
continue
+
+ #Extract the recipe and version
package = str(fail['package'])
g = re.match(r'(.*)\-(\d.*)', package)
- f = BuildFailure(TASK = str(fail['task']), RECIPE = g.group(1), RECIPE_VERSION = g.group(2), ERROR_DETAILS = str(fail['log']), BUILD = b)
+ if g and g.lastindex == 2:
+ recipe = g.group(1)
+ recipe_version = g.group(2)
+ else:
+ recipe = package
+ recipe_version = "unknown"
+
+ f = BuildFailure(TASK = str(fail['task']), RECIPE = recipe, RECIPE_VERSION = recipe_version, ERROR_DETAILS = str(fail['log']), BUILD = b)
f.save()
url = 'http://' + host + reverse('details', args=[f.id])