Bug 9670

Summary: Toaster does not set a correct MIME type for tasks' logs files
Product: [Build System, Metadata & Runtime] Toaster Reporter: Leif Middelschulte <Leif.Middelschulte>
Component: toasterAssignee: Toaster default assignee <toaster>
Status: NEW --- QA Contact:
Severity: normal    
Priority: Low CC: belen.barros.pena, brian.avery, david.reyna, jessica.zhang, jose.perez.carranza, joshuagloe, stanciux.mihail
Version: unspecified   
Target Milestone: Future   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Leif Middelschulte 2016-05-24 11:38:43 UTC
Toaster (i.e. "source toaster start) does not set the correct header for tasks' log files. This leads to browsers not offering to open the files in place, resulting in an annoying work flow.
Comment 1 Elliot Smith 2016-05-25 15:38:17 UTC
Would be better to use python-magic rather than the Python mimetypes module, as the mimetypes module relies on file extensions and log files use the PID for the file extension.
Comment 2 brian avery 2016-05-25 16:34:34 UTC
we could try something like:
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -67,7 +67,10 @@ class MimeTypeFinder(object):
         guess = mimetypes.guess_type(path, self._strict)
         guessed_type = guess[0]
         if guessed_type == None:
-            guessed_type = 'application/octet-stream'
+            if "log.do_" in os.path.basename(path):
+                guessed_type = 'text/plain'
+            else:
+                guessed_type = 'application/octet-stream'
         return guessed_type


since we are already providing a base guess at least it would keep any special cases in one place.