[Toaster] [PATCH 4/6] toaster: add get_target_objects API

Smith, Elliot elliot.smith at intel.com
Mon Sep 28 02:41:07 PDT 2015


On 28 September 2015 at 09:57, Ed Bartosh <ed.bartosh at linux.intel.com>
wrote:

> Target objects are created before the build if build is
> started from UI in build mode. However, in analysis mode Target
> objects don't exist and need to be created using information
> from bitbake events.
>
> Added new API call get_target_objects to retrive existing
> target objects or create them if they don't exist yet.
>
> Signed-off-by: Ed Bartosh <ed.bartosh at linux.intel.com>
> ---
>  bitbake/lib/bb/ui/buildinfohelper.py | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/bitbake/lib/bb/ui/buildinfohelper.py
> b/bitbake/lib/bb/ui/buildinfohelper.py
> index 6a26172..50640e73 100644
> --- a/bitbake/lib/bb/ui/buildinfohelper.py
> +++ b/bitbake/lib/bb/ui/buildinfohelper.py
> @@ -181,6 +181,20 @@ class ORMWrapper(object):
>
>          return build
>
> +    @staticmethod
> +    def get_target_objects(target_info):
> +        result = []
> +        for target in target_info['targets']:
> +            obj, created =
> Target.objects.get_or_create(build=target_info['build'],
> +                                                        target=target)
> +            if created:
> +                obj.is_image = False
> +                if target_info['task']:
> +                    obj.task = target_info['task']
> +                obj.save()
> +            result.append(obj)
> +        return result
> +
>

I think we should call this get_or_create_target_objects(), for consistency
with existing methods, and also to highlight that the method has potential
database writes as a side effect.

Elliot



>      def update_build_object(self, build, errors, warnings, taskfailures):
>          assert isinstance(build,Build)
>          assert isinstance(errors, int)
> @@ -861,7 +875,7 @@ class BuildInfoHelper(object):
>              task = task[3:]
>          target_information['task'] = task
>
> -        self.internal_state['targets'] =
> Target.objects.filter(build=target_information['build'])
> +        self.internal_state['targets'] =
> self.orm_wrapper.get_target_objects(target_information)
>
>          # Save build configuration
>          data = self.server.runCommand(["getAllKeysWithFlags", ["doc",
> "func"]])[0]
> --
> 2.1.4
>
> --
> _______________________________________________
> toaster mailing list
> toaster at yoctoproject.org
> https://lists.yoctoproject.org/listinfo/toaster
>



-- 
Elliot Smith
Software Engineer
Intel Open Source Technology Centre
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/toaster/attachments/20150928/3fa33db9/attachment.html>


More information about the toaster mailing list