Create new generic function save_error_report  based on _saveBitbakeErrorReport
in order to use the same function on OESelftest error reports.

Signed-off-by: Aníbal Limón <anibal.li...@linux.intel.com>
---
 .../site-packages/autobuilder/lib/ABTools.py       | 13 ++++++++++++
 .../site-packages/autobuilder/lib/buildsteps.py    | 23 +++++-----------------
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/lib/python2.7/site-packages/autobuilder/lib/ABTools.py 
b/lib/python2.7/site-packages/autobuilder/lib/ABTools.py
index 579ae85..1e09de7 100644
--- a/lib/python2.7/site-packages/autobuilder/lib/ABTools.py
+++ b/lib/python2.7/site-packages/autobuilder/lib/ABTools.py
@@ -11,6 +11,9 @@ __email__ = "elizabeth.flana...@intel.com"
 '''
 
 import os
+import time
+import json
+import codecs
 
 from autobuilder.config import YOCTO_ABBASE
 
@@ -35,3 +38,13 @@ def get_error_report_worker_dir(buildername):
         errordir = os.environ.get('ERROR_REPORT_DIR')
 
     return errordir
+
+def save_error_report(buildername, buildnumber, report, report_type):
+    errordir = get_error_report_controller_dir(buildername, buildnumber)
+    if not os.path.exists(errordir):
+        os.makedirs(errordir)
+
+    filename = os.path.join(errordir, "error_report_%s_%d.txt" % \
+            (report_type, int(time.time())))
+    with codecs.open(filename, 'w', 'utf-8') as f:
+        json.dump(report, f, indent=4, sort_keys=True)
diff --git a/lib/python2.7/site-packages/autobuilder/lib/buildsteps.py 
b/lib/python2.7/site-packages/autobuilder/lib/buildsteps.py
index c290218..eee0c1b 100644
--- a/lib/python2.7/site-packages/autobuilder/lib/buildsteps.py
+++ b/lib/python2.7/site-packages/autobuilder/lib/buildsteps.py
@@ -13,14 +13,11 @@ __email__ = "anibal.li...@linux.intel.com"
 import os
 import re
 
-import time
-import json
-import codecs
 
 from buildbot.steps.shell import ShellCommand
 from buildbot.process.buildstep import LogLineObserver
 
-from lib.ABTools import get_error_report_controller_dir
+from lib.ABTools import save_error_report
 
 DEFAULT_SHELL = 'bash'
 
@@ -139,21 +136,11 @@ class BitbakeShellCommand(ShellCommand):
 
         return report
 
-    def _saveBitbakeErrorReport(self, report):
-        buildername = self.getProperty('buildername')
-        buildnumber = self.getProperty('buildnumber')
-
-        errordir = get_error_report_controller_dir(buildername, buildnumber)
-        if not os.path.exists(errordir):
-            os.makedirs(errordir)
-
-        filename = os.path.join(errordir, "error_report_bitbake_%d.txt" % \
-                int(time.time()))
-        with codecs.open(filename, 'w', 'utf-8') as f:
-            json.dump(report, f, indent=4, sort_keys=True)
-
     def commandComplete(self, cmd):
         if cmd.didFail():
             if self.errors['bitbake']:
+                buildername = self.getProperty('buildername')
+                buildnumber = self.getProperty('buildnumber')
+
                 report = self._createBitbakeErrorReport(self.errors['log'])
-                self._saveBitbakeErrorReport(report)
+                save_error_report(buildername, buildnumber, report, 'bitbake')
-- 
2.1.4

-- 
_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto

Reply via email to