summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2015-05-01 16:20:33 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-08 17:42:05 +0100
commit7759cd4931b2e7af19eea79dfac6738a92687665 (patch)
treee09e11a14b04e02e9902b76505cf3f651d577edc /bitbake
parent4a711028c709d4bb1421e1637ae3fb0ac404fb45 (diff)
downloadpoky-7759cd4931b2e7af19eea79dfac6738a92687665.tar.gz
bitbake: toasterui: proper exit code on toaster errors
This patch modifies the toasterui to properly return the exit code based on the errors found in the toaster itself. The upload event file API call will not delete event logs for which toasterui showed an error. This will facilitate debugging. Minor enhancement in the buildinfohelper to reduce the number of lookups on unknown layer objects (prevented testing of the patch). (Bitbake rev: 1ddd6a9e4280a4adf971132ff1fe7ec9b3252905) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rwxr-xr-xbitbake/bin/toaster-eventreplay13
-rw-r--r--bitbake/lib/bb/ui/buildinfohelper.py5
-rw-r--r--bitbake/lib/bb/ui/toasterui.py11
-rw-r--r--bitbake/lib/toaster/orm/views.py8
4 files changed, 19 insertions, 18 deletions
diff --git a/bitbake/bin/toaster-eventreplay b/bitbake/bin/toaster-eventreplay
index 624829aea0..615a7aed15 100755
--- a/bitbake/bin/toaster-eventreplay
+++ b/bitbake/bin/toaster-eventreplay
@@ -26,6 +26,7 @@
26# as a build eventlog, and the ToasterUI is used to process events in the file 26# as a build eventlog, and the ToasterUI is used to process events in the file
27# and log data in the database 27# and log data in the database
28 28
29from __future__ import print_function
29import os 30import os
30import sys, logging 31import sys, logging
31 32
@@ -39,12 +40,6 @@ from bb.ui import toasterui
39import sys 40import sys
40import logging 41import logging
41 42
42logger = logging.getLogger(__name__)
43console = logging.StreamHandler(sys.stdout)
44format_str = "%(levelname)s: %(message)s"
45logging.basicConfig(format=format_str)
46
47
48import json, pickle 43import json, pickle
49 44
50 45
@@ -168,12 +163,12 @@ class MockConfigParameters():
168# run toaster ui on our mock bitbake class 163# run toaster ui on our mock bitbake class
169if __name__ == "__main__": 164if __name__ == "__main__":
170 if len(sys.argv) < 2: 165 if len(sys.argv) < 2:
171 logger.error("Usage: %s event.log " % sys.argv[0]) 166 print("Usage: %s event.log " % sys.argv[0])
172 sys.exit(1) 167 sys.exit(1)
173 168
174 file_name = sys.argv[-1] 169 file_name = sys.argv[-1]
175 mock_connection = FileReadEventsServerConnection(file_name) 170 mock_connection = FileReadEventsServerConnection(file_name)
176 configParams = MockConfigParameters() 171 configParams = MockConfigParameters()
177 172
178 # run the main program 173 # run the main program and set exit code to the returned value
179 toasterui.main(mock_connection.connection, mock_connection.events, configParams) 174 sys.exit(toasterui.main(mock_connection.connection, mock_connection.events, configParams))
diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py
index 64bd94e5e8..647d663cb5 100644
--- a/bitbake/lib/bb/ui/buildinfohelper.py
+++ b/bitbake/lib/bb/ui/buildinfohelper.py
@@ -718,12 +718,15 @@ class BuildInfoHelper(object):
718 return lvo 718 return lvo
719 719
720 #if we get here, we didn't read layers correctly; dump whatever information we have on the error log 720 #if we get here, we didn't read layers correctly; dump whatever information we have on the error log
721 logger.error("Could not match layer version for recipe path %s : %s" % (path, self.orm_wrapper.layer_version_objects)) 721 logger.warn("Could not match layer version for recipe path %s : %s" % (path, self.orm_wrapper.layer_version_objects))
722 722
723 #mockup the new layer 723 #mockup the new layer
724 unknown_layer, created = Layer.objects.get_or_create(name="__FIXME__unidentified_layer", local_path="/", layer_index_url="") 724 unknown_layer, created = Layer.objects.get_or_create(name="__FIXME__unidentified_layer", local_path="/", layer_index_url="")
725 unknown_layer_version_obj, created = Layer_Version.objects.get_or_create(layer = unknown_layer, build = self.internal_state['build']) 725 unknown_layer_version_obj, created = Layer_Version.objects.get_or_create(layer = unknown_layer, build = self.internal_state['build'])
726 726
727 # append it so we don't run into this error again and again
728 self.orm_wrapper.layer_version_objects.append(unknown_layer_version_obj)
729
727 return unknown_layer_version_obj 730 return unknown_layer_version_obj
728 731
729 def _get_recipe_information_from_taskfile(self, taskfile): 732 def _get_recipe_information_from_taskfile(self, taskfile):
diff --git a/bitbake/lib/bb/ui/toasterui.py b/bitbake/lib/bb/ui/toasterui.py
index f0f853be14..6a7a1cd174 100644
--- a/bitbake/lib/bb/ui/toasterui.py
+++ b/bitbake/lib/bb/ui/toasterui.py
@@ -88,7 +88,7 @@ def main(server, eventHandler, params ):
88 88
89 if not params.observe_only: 89 if not params.observe_only:
90 logger.error("ToasterUI can only work in observer mode") 90 logger.error("ToasterUI can only work in observer mode")
91 return 91 return 1
92 92
93 93
94 main.shutdown = 0 94 main.shutdown = 0
@@ -144,7 +144,6 @@ def main(server, eventHandler, params ):
144 buildinfohelper.store_log_event(event) 144 buildinfohelper.store_log_event(event)
145 if event.levelno >= format.ERROR: 145 if event.levelno >= format.ERROR:
146 errors = errors + 1 146 errors = errors + 1
147 return_value = 1
148 elif event.levelno == format.WARNING: 147 elif event.levelno == format.WARNING:
149 warnings = warnings + 1 148 warnings = warnings + 1
150 # For "normal" logging conditions, don't show note logs from tasks 149 # For "normal" logging conditions, don't show note logs from tasks
@@ -158,7 +157,6 @@ def main(server, eventHandler, params ):
158 157
159 if isinstance(event, bb.build.TaskFailed): 158 if isinstance(event, bb.build.TaskFailed):
160 buildinfohelper.update_and_store_task(event) 159 buildinfohelper.update_and_store_task(event)
161 return_value = 1
162 logfile = event.logfile 160 logfile = event.logfile
163 if logfile and os.path.exists(logfile): 161 if logfile and os.path.exists(logfile):
164 bb.error("Logfile of failure stored in: %s" % logfile) 162 bb.error("Logfile of failure stored in: %s" % logfile)
@@ -188,7 +186,6 @@ def main(server, eventHandler, params ):
188 continue 186 continue
189 187
190 if isinstance(event, bb.event.NoProvider): 188 if isinstance(event, bb.event.NoProvider):
191 return_value = 1
192 errors = errors + 1 189 errors = errors + 1
193 if event._runtime: 190 if event._runtime:
194 r = "R" 191 r = "R"
@@ -316,6 +313,7 @@ def main(server, eventHandler, params ):
316 continue 313 continue
317 314
318 logger.error("Unknown event: %s", event) 315 logger.error("Unknown event: %s", event)
316 return_value += 1
319 317
320 except EnvironmentError as ioerror: 318 except EnvironmentError as ioerror:
321 # ignore interrupted io 319 # ignore interrupted io
@@ -344,10 +342,13 @@ def main(server, eventHandler, params ):
344 except Exception as ce: 342 except Exception as ce:
345 logger.error("CRITICAL - Failed to to save toaster exception to the database: %s" % str(ce)) 343 logger.error("CRITICAL - Failed to to save toaster exception to the database: %s" % str(ce))
346 344
345 # make sure we return with an error
346 return_value += 1
347 pass 347 pass
348 348
349 if interrupted: 349 if interrupted:
350 if return_value == 0: 350 if return_value == 0:
351 return_value = 1 351 return_value += 1
352 352
353 logger.warn("Return value is %d", return_value)
353 return return_value 354 return return_value
diff --git a/bitbake/lib/toaster/orm/views.py b/bitbake/lib/toaster/orm/views.py
index 97d792b99e..61d14f9375 100644
--- a/bitbake/lib/toaster/orm/views.py
+++ b/bitbake/lib/toaster/orm/views.py
@@ -55,6 +55,8 @@ def eventfile(request):
55 scriptenv["DATABASE_URL"] = toastermain.settings.getDATABASE_URL() 55 scriptenv["DATABASE_URL"] = toastermain.settings.getDATABASE_URL()
56 56
57 # run the data loading process and return the results 57 # run the data loading process and return the results
58 (out, err) = subprocess.Popen([import_script, abstemppath], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=scriptenv).communicate() 58 importer = subprocess.Popen([import_script, abstemppath], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=scriptenv)
59 os.remove(abstemppath) 59 (out, err) = importer.communicate()
60 return HttpResponse("%s\n%s" % (out, err), content_type="text/plain;utf8") 60 if importer.returncode == 0:
61 os.remove(abstemppath)
62 return HttpResponse("== Retval %d\n== STDOUT\n%s\n\n== STDERR\n%s" % (importer.returncode, out, err), content_type="text/plain;utf8")