[yocto-autobuilder2][PATCH 3/4] steps/runconfig: Refactor log helper to module-level add_to_log

Yoann Congal <[email protected]>
Newsgroups org.yoctoproject.lists.yocto-patches
Message-ID <[email protected]>
From: Yoann Congal <[email protected]>

This will allow to call add_to_log elsewhere in a later commit.

Signed-off-by: Yoann Congal <[email protected]>
---
 steps/runconfig.py | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/steps/runconfig.py b/steps/runconfig.py
index a6d0dbd..18cdd7a 100644
--- a/steps/runconfig.py
+++ b/steps/runconfig.py
@@ -154,6 +154,14 @@ def get_runconfig_step(name, stepname, phase, description, usepty, posttrigger):
         timeout=16200)  # default of 1200s/20min is too short, use 4.5hrs
     return step
 
[email protected]
+def add_to_log(step, logName, message):
+    try:
+        log = step.getLog(logName)
+    except KeyError:
+        log = yield step.addLog(logName)
+    log.addStdout(message)
+
 class RunConfigCheckSteps(shell.ShellCommand):
     name = 'Check run-config steps to use'
     descriptionDone = ['Checked which run-config approach to use']
@@ -192,7 +200,7 @@ class RunConfigCheckSteps(shell.ShellCommand):
         try:
             jsonconfig = json.loads(logLines)
         except Exception as ex:
-            self._addToLog('stderr', 'ERROR: unable to parse data, exception {}: {}'.format(ex.__class__, ex))
+            add_to_log(self, 'stderr', 'ERROR: unable to parse data, exception {}: {}'.format(ex.__class__, ex))
 
         if rc == FAILURE or not jsonconfig:
             steps = [get_runconfig_legacy_step(self.posttrigger)]
@@ -209,14 +217,6 @@ class RunConfigCheckSteps(shell.ShellCommand):
         self.build.addStepsAfterCurrentStep(steps)
         return SUCCESS
 
-    @defer.inlineCallbacks
-    def _addToLog(self, logName, message):
-        try:
-            log = self.getLog(logName)
-        except KeyError:
-            log = yield self.addLog(logName)
-        log.addStdout(message)
-
 class TargetPresent(shell.ShellCommand):
     name = "Check if branch needs this target"
     command=[util.Interpolate("%(prop:builddir)s/yocto-autobuilder-helper/scripts/target-present"), util.Property("buildername")]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.