diff mbox series

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

Message ID 20260525210708.2918572-3-yoann.congal@smile.fr
State New
Headers show
Series [yocto-autobuilder2,1/4] docker: Switch RO git URL from git:// to https:// | expand

Commit Message

Yoann Congal May 25, 2026, 9:07 p.m. UTC
From: Yoann Congal <yoann.congal@smile.fr>

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

Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
---
 steps/runconfig.py | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
diff mbox series

Patch

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
 
+@defer.inlineCallbacks
+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")]