summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/ui/buildinfohelper.py9
-rw-r--r--bitbake/lib/toaster/orm/models.py23
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py2
3 files changed, 23 insertions, 11 deletions
diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py
index c09955157a..87e03e7c61 100644
--- a/bitbake/lib/bb/ui/buildinfohelper.py
+++ b/bitbake/lib/bb/ui/buildinfohelper.py
@@ -146,7 +146,7 @@ class ORMWrapper(object):
146 prj = Project.objects.get(pk = project_id) 146 prj = Project.objects.get(pk = project_id)
147 147
148 else: # this build was triggered by a legacy system, or command line interactive mode 148 else: # this build was triggered by a legacy system, or command line interactive mode
149 prj = Project.objects.get_default_project() 149 prj = Project.objects.get_or_create_default_project()
150 logger.debug(1, "buildinfohelper: project is not specified, defaulting to %s" % prj) 150 logger.debug(1, "buildinfohelper: project is not specified, defaulting to %s" % prj)
151 151
152 152
@@ -308,6 +308,11 @@ class ORMWrapper(object):
308 # then we are wholly responsible for the data 308 # then we are wholly responsible for the data
309 # and therefore we return the 'real' recipe rather than the build 309 # and therefore we return the 'real' recipe rather than the build
310 # history copy of the recipe. 310 # history copy of the recipe.
311 if recipe_information['layer_version'].build is not None and \
312 recipe_information['layer_version'].build.project == \
313 Project.objects.get_or_create_default_project():
314 return recipe
315
311 if built_recipe is None: 316 if built_recipe is None:
312 return recipe 317 return recipe
313 318
@@ -345,7 +350,7 @@ class ORMWrapper(object):
345 # If we're doing a command line build then associate this new layer with the 350 # If we're doing a command line build then associate this new layer with the
346 # project to avoid it 'contaminating' toaster data 351 # project to avoid it 'contaminating' toaster data
347 project = None 352 project = None
348 if build_obj.project == Project.objects.get_default_project(): 353 if build_obj.project == Project.objects.get_or_create_default_project():
349 project = build_obj.project 354 project = build_obj.project
350 355
351 layer_version_object, _ = Layer_Version.objects.get_or_create( 356 layer_version_object, _ = Layer_Version.objects.get_or_create(
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 0174233498..4a868e7ded 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -91,18 +91,25 @@ class ProjectManager(models.Manager):
91 91
92 return prj 92 return prj
93 93
94 def create(self, *args, **kwargs):
95 raise Exception("Invalid call to Project.objects.create. Use Project.objects.create_project() to create a project")
96
97 # return single object with is_default = True 94 # return single object with is_default = True
98 def get_default_project(self): 95 def get_or_create_default_project(self):
99 projects = super(ProjectManager, self).filter(is_default = True) 96 projects = super(ProjectManager, self).filter(is_default = True)
97
100 if len(projects) > 1: 98 if len(projects) > 1:
101 raise Exception("Inconsistent project data: multiple " + 99 raise Exception('Inconsistent project data: multiple ' +
102 "default projects (i.e. with is_default=True)") 100 'default projects (i.e. with is_default=True)')
103 elif len(projects) < 1: 101 elif len(projects) < 1:
104 raise Exception("Inconsistent project data: no default project found") 102 options = {
105 return projects[0] 103 'name': 'Command line builds',
104 'short_description': 'Project for builds started outside Toaster',
105 'is_default': True
106 }
107 project = Project.objects.create(**options)
108 project.save()
109
110 return project
111 else:
112 return projects[0]
106 113
107class Project(models.Model): 114class Project(models.Model):
108 search_allowed_fields = ['name', 'short_description', 'release__name', 'release__branch_name'] 115 search_allowed_fields = ['name', 'short_description', 'release__name', 'release__branch_name']
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 243bb09d62..16f27b8022 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -73,7 +73,7 @@ class MimeTypeFinder(object):
73def landing(request): 73def landing(request):
74 # in build mode, we redirect to the command-line builds page 74 # in build mode, we redirect to the command-line builds page
75 # if there are any builds for the default (cli builds) project 75 # if there are any builds for the default (cli builds) project
76 default_project = Project.objects.get_default_project() 76 default_project = Project.objects.get_or_create_default_project()
77 default_project_builds = Build.objects.filter(project = default_project) 77 default_project_builds = Build.objects.filter(project = default_project)
78 78
79 # we only redirect to projects page if there is a user-generated project 79 # we only redirect to projects page if there is a user-generated project