Skip to contentSkip to conversation

toaster: Manually retrieve log file location from filesystem

PATCH Superseded Elliot Smith 2 participants 2 messages Sep 28, 2015 – Sep 29, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 toaster: Manually retrieve log file location from filesystem

The log file location reported by the BB_CONSOLELOG variable does not point to the log location for the current build at the time when the BuildStarted event is fired. It actually points to the location where the next build will log to. This means that the log file paths associated with a build in the cooker_log_path field are incorrect, with the result that the "Download build log" button doesn't work.

Instead, when a build starts, get the latest-dated log file and associate it with the build.

An issue explaining why this is a problem, plus steps to demonstrate it:
https://bugzilla.yoctoproject.org/show_bug.cgi?id=8411

This patch is a temporary workaround for issue 8411, as discussed in
https://bugzilla.yoctoproject.org/show_bug.cgi?id=8373#c2
It fixes 8373 for now, but should be properly fixed if bitbake can provide the correct log location at the point when BuildStarted is fired.

[YOCTO #8373]

---
 bitbake/lib/bb/ui/toasterui.py | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)
bitbake/lib/bb/ui/toasterui.py +30 -1
index e0c278b..be4518c 100644
@@ -33,6 +33,7 @@ from bb.ui.buildinfohelper import BuildInfoHelper
 import bb.msg
 import logging
 import os
+import glob
 
 # pylint: disable=invalid-name
 # module properties for UI modules are read by bitbake and the contract should not be broken
@@ -61,6 +62,33 @@ def _log_settings_from_server(server):
         raise BaseException(error)
     return includelogs, loglines, consolelogfile
 
+# TODO this is a work-around for the bug mentioned in
+# https://bugzilla.yoctoproject.org/show_bug.cgi?id=8373#c2
+# - the log file location reported by BB_CONSOLELOG at the point
+# when the BuildStarted event occurs does not correspond to the
+# actual log file location;
+# as a work-around, we get the latest-dated log file in the same
+# directory as is in the path stored in BB_CONSOLELOG
+#
+# consolelogfile: log file location reported by BB_CONSOLELOG
+# at the point when a build starts, which isn't the actual log location;
+# the assumption is that the real log file will be in the same
+# directory as the reported log file
+#
+# returns the latest-dated *.log file in the same directory
+# as consolelogfile; if there are no *.log files, this returns
+# consolelogfile
+def _get_real_log_file(consolelogfile):
+    log_file_dir = os.path.dirname(consolelogfile)
+    log_file_pattern = os.path.join(log_file_dir, "*.log")
+    log_files = glob.glob(log_file_pattern)
+    log_files = filter(os.path.isfile, log_files)
+    log_files.sort(key=os.path.getmtime)
+
+    if len(log_files) > 0:
+        return log_files[-1]
+    else:
+        return consolelogfile
 
 def main(server, eventHandler, params ):
     helper = uihelper.BBUIHelper()
@@ -126,7 +154,8 @@ def main(server, eventHandler, params ):
             # the code will look into the protected variables of the event; no easy way around this
 
             if isinstance(event, bb.event.BuildStarted):
-                buildinfohelper.store_started_build(event, consolelogfile)
+                real_consolelogfile = _get_real_log_file(consolelogfile)
+                buildinfohelper.store_started_build(event, real_consolelogfile)
 
             if isinstance(event, (bb.build.TaskStarted, bb.build.TaskSucceeded, bb.build.TaskFailedSilent)):
                 buildinfohelper.update_and_store_task(event)
Signature · 14 lines
Elliot Smith
Software Engineer
Intel OTC

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
#1 lore raw
Quoted 15 lines · On 28/09/2015 20:24, "[email protected] on behalf of Elliot…

The log file location reported by the BB_CONSOLELOG variable does not point to the log location for the current build at the time when the BuildStarted event is fired. It actually points to the location where the next build will log to. This means that the log file paths associated with a build in the cooker_log_path field are incorrect, with the result that the "Download build log" button doesn't work.

Instead, when a build starts, get the latest-dated log file and associate it with the build.

An issue explaining why this is a problem, plus steps to demonstrate it:
https://bugzilla.yoctoproject.org/show_bug.cgi?id=8411

Quoted 8 lines

This patch is a temporary workaround for issue 8411, as discussed in
https://bugzilla.yoctoproject.org/show_bug.cgi?id=8373#c2
It fixes 8373 for now, but should be properly fixed if bitbake can provide the correct log location at the point when BuildStarted is fired.

[YOCTO #8373]

This works for me.

Thanks!

Belén

Quoted 89 lines

---
bitbake/lib/bb/ui/toasterui.py | 31 ++++++++++++++++++++++++++++++-

1 file changed, 30 insertions(+), 1 deletion(-)
bitbake/lib/bb/ui/toasterui.py +0 -0
index e0c278b..be4518c 100644
@@ -33,6 +33,7 @@ from bb.ui.buildinfohelper import BuildInfoHelper

import bb.msg
import logging
import os
+import glob

# pylint: disable=invalid-name

# module properties for UI modules are read by bitbake and the contract
should not be broken
bitbake/lib/bb/ui/toasterui.py +27 -0
@@ -61,6 +62,33 @@ def _log_settings_from_server(server):
        raise BaseException(error)
    return includelogs, loglines, consolelogfile
 
+# TODO this is a work-around for the bug mentioned in
+# https://bugzilla.yoctoproject.org/show_bug.cgi?id=8373#c2
+# - the log file location reported by BB_CONSOLELOG at the point
+# when the BuildStarted event occurs does not correspond to the
+# actual log file location;
+# as a work-around, we get the latest-dated log file in the same
+# directory as is in the path stored in BB_CONSOLELOG
+#
+# consolelogfile: log file location reported by BB_CONSOLELOG
+# at the point when a build starts, which isn't the actual log location;
+# the assumption is that the real log file will be in the same
+# directory as the reported log file
+#
+# returns the latest-dated *.log file in the same directory
+# as consolelogfile; if there are no *.log files, this returns
+# consolelogfile
+def _get_real_log_file(consolelogfile):
+    log_file_dir = os.path.dirname(consolelogfile)
+    log_file_pattern = os.path.join(log_file_dir, "*.log")
+    log_files = glob.glob(log_file_pattern)
+    log_files = filter(os.path.isfile, log_files)
+    log_files.sort(key=os.path.getmtime)
+
+    if len(log_files) > 0:
+        return log_files[-1]
+    else:
+        return consolelogfile
 

def main(server, eventHandler, params ):
helper = uihelper.BBUIHelper()

bitbake/lib/bb/ui/toasterui.py +0 -0
@@ -126,7 +154,8 @@ def main(server, eventHandler, params ):
            # the code will look into the protected variables of the

event; no easy way around this

if isinstance(event, bb.event.BuildStarted):
- buildinfohelper.store_started_build(event,
consolelogfile)

bitbake/lib/bb/ui/toasterui.py +2 -0
+                real_consolelogfile = _get_real_log_file(consolelogfile)
+                buildinfohelper.store_started_build(event,

real_consolelogfile)

if isinstance(event, (bb.build.TaskStarted,
bb.build.TaskSucceeded, bb.build.TaskFailedSilent)):
buildinfohelper.update_and_store_task(event)

Signature · 20 lines
Elliot Smith
Software Engineer
Intel OTC

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

-- 
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster