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>
# as a build eventlog, and the ToasterUI is used to process events in the file
# and log data in the database
+from __future__ import print_function
import os
import sys, logging
import sys
import logging
-logger = logging.getLogger(__name__)
-console = logging.StreamHandler(sys.stdout)
-format_str = "%(levelname)s: %(message)s"
-logging.basicConfig(format=format_str)
-
-
import json, pickle
# run toaster ui on our mock bitbake class
if __name__ == "__main__":
if len(sys.argv) < 2:
- logger.error("Usage: %s event.log " % sys.argv[0])
+ print("Usage: %s event.log " % sys.argv[0])
sys.exit(1)
file_name = sys.argv[-1]
mock_connection = FileReadEventsServerConnection(file_name)
configParams = MockConfigParameters()
- # run the main program
- toasterui.main(mock_connection.connection, mock_connection.events, configParams)
+ # run the main program and set exit code to the returned value
+ sys.exit(toasterui.main(mock_connection.connection, mock_connection.events, configParams))
return lvo
#if we get here, we didn't read layers correctly; dump whatever information we have on the error log
- logger.error("Could not match layer version for recipe path %s : %s" % (path, self.orm_wrapper.layer_version_objects))
+ logger.warn("Could not match layer version for recipe path %s : %s" % (path, self.orm_wrapper.layer_version_objects))
#mockup the new layer
unknown_layer, created = Layer.objects.get_or_create(name="__FIXME__unidentified_layer", local_path="/", layer_index_url="")
unknown_layer_version_obj, created = Layer_Version.objects.get_or_create(layer = unknown_layer, build = self.internal_state['build'])
+ # append it so we don't run into this error again and again
+ self.orm_wrapper.layer_version_objects.append(unknown_layer_version_obj)
+
return unknown_layer_version_obj
def _get_recipe_information_from_taskfile(self, taskfile):
if not params.observe_only:
logger.error("ToasterUI can only work in observer mode")
- return
+ return 1
main.shutdown = 0
buildinfohelper.store_log_event(event)
if event.levelno >= format.ERROR:
errors = errors + 1
- return_value = 1
elif event.levelno == format.WARNING:
warnings = warnings + 1
# For "normal" logging conditions, don't show note logs from tasks
if isinstance(event, bb.build.TaskFailed):
buildinfohelper.update_and_store_task(event)
- return_value = 1
logfile = event.logfile
if logfile and os.path.exists(logfile):
bb.error("Logfile of failure stored in: %s" % logfile)
continue
if isinstance(event, bb.event.NoProvider):
- return_value = 1
errors = errors + 1
if event._runtime:
r = "R"
continue
logger.error("Unknown event: %s", event)
+ return_value += 1
except EnvironmentError as ioerror:
# ignore interrupted io
except Exception as ce:
logger.error("CRITICAL - Failed to to save toaster exception to the database: %s" % str(ce))
+ # make sure we return with an error
+ return_value += 1
pass
if interrupted:
if return_value == 0:
- return_value = 1
+ return_value += 1
+ logger.warn("Return value is %d", return_value)
return return_value
scriptenv["DATABASE_URL"] = toastermain.settings.getDATABASE_URL()
# run the data loading process and return the results
- (out, err) = subprocess.Popen([import_script, abstemppath], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=scriptenv).communicate()
- os.remove(abstemppath)
- return HttpResponse("%s\n%s" % (out, err), content_type="text/plain;utf8")
+ importer = subprocess.Popen([import_script, abstemppath], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=scriptenv)
+ (out, err) = importer.communicate()
+ if importer.returncode == 0:
+ os.remove(abstemppath)
+ return HttpResponse("== Retval %d\n== STDOUT\n%s\n\n== STDERR\n%s" % (importer.returncode, out, err), content_type="text/plain;utf8")