summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2014-09-30 13:45:51 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-10-30 13:39:50 +0000
commitc7382dbd8bb273062164e7cdb7233b60874c91d3 (patch)
treef566e2290a12c4ca4d0b921e6b7c4cb8e76d9b24 /bitbake/lib/toaster
parent477587b99616911665055af67ccbfa7abbc48116 (diff)
downloadopenembedded-core-contrib-c7382dbd8bb273062164e7cdb7233b60874c91d3.tar.gz
bitbake: toastergui: protect variable value reads
We make sure we don't throw an exception when reading non-existent variables from the database, and we return empty data that can be displayed without ill effects. This fixes the Configuration page on empty builds. (Bitbake rev: 5b13eabdec1e8a052d343fd67654d7fe8974224f) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster')
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py26
1 files changed, 17 insertions, 9 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 6a13a99bae..66113cfdf3 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -1249,15 +1249,23 @@ def configuration(request, build_id):
template = 'configuration.html'
variables = Variable.objects.filter(build=build_id)
- BB_VERSION=variables.get(variable_name='BB_VERSION').variable_value
- BUILD_SYS=variables.get(variable_name='BUILD_SYS').variable_value
- NATIVELSBSTRING=variables.get(variable_name='NATIVELSBSTRING').variable_value
- TARGET_SYS=variables.get(variable_name='TARGET_SYS').variable_value
- MACHINE=variables.get(variable_name='MACHINE').variable_value
- DISTRO=variables.get(variable_name='DISTRO').variable_value
- DISTRO_VERSION=variables.get(variable_name='DISTRO_VERSION').variable_value
- TUNE_FEATURES=variables.get(variable_name='TUNE_FEATURES').variable_value
- TARGET_FPU=variables.get(variable_name='TARGET_FPU').variable_value
+
+ def _get_variable_or_empty(variable_name):
+ from django.core.exceptions import ObjectDoesNotExist
+ try:
+ return variables.get(variable_name=variable_name).variable_value
+ except ObjectDoesNotExist:
+ return ''
+
+ BB_VERSION=_get_variable_or_empty(variable_name='BB_VERSION')
+ BUILD_SYS=_get_variable_or_empty(variable_name='BUILD_SYS')
+ NATIVELSBSTRING=_get_variable_or_empty(variable_name='NATIVELSBSTRING')
+ TARGET_SYS=_get_variable_or_empty(variable_name='TARGET_SYS')
+ MACHINE=_get_variable_or_empty(variable_name='MACHINE')
+ DISTRO=_get_variable_or_empty(variable_name='DISTRO')
+ DISTRO_VERSION=_get_variable_or_empty(variable_name='DISTRO_VERSION')
+ TUNE_FEATURES=_get_variable_or_empty(variable_name='TUNE_FEATURES')
+ TARGET_FPU=_get_variable_or_empty(variable_name='TARGET_FPU')
targets = Target.objects.filter(build=build_id)