mirror of
https://git.yoctoproject.org/poky
synced 2026-02-25 19:09:41 +01:00
bitbake: toaster/widgets.py: avoid divide by zero issues
There can be cases where the variables being used to divide in build percentage expressions can be zero. For example, a setup consisting of only local repos will have repos_to_clone=0 and will generate a divide by zero scenario. Fix this by checking the divisor in such cases. [YOCTO #12891] (Bitbake rev: 30702f29928c3b088f199bf8b1609b2956f8c47a) Signed-off-by: Awais Belal <awais_belal@mentor.com> Signed-off-by: David Reyna <David.Reyna@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
90a9b1b0f5
commit
61428c05bb
@@ -511,13 +511,18 @@ class MostRecentBuildsView(View):
|
||||
buildrequest_id = build_obj.buildrequest.pk
|
||||
build['buildrequest_id'] = buildrequest_id
|
||||
|
||||
build['recipes_parsed_percentage'] = \
|
||||
int((build_obj.recipes_parsed /
|
||||
build_obj.recipes_to_parse) * 100)
|
||||
|
||||
build['repos_cloned_percentage'] = \
|
||||
int((build_obj.repos_cloned /
|
||||
build_obj.repos_to_clone) * 100)
|
||||
if build_obj.recipes_to_parse > 0:
|
||||
build['recipes_parsed_percentage'] = \
|
||||
int((build_obj.recipes_parsed /
|
||||
build_obj.recipes_to_parse) * 100)
|
||||
else:
|
||||
build['recipes_parsed_percentage'] = 0
|
||||
if build_obj.repos_to_clone > 0:
|
||||
build['repos_cloned_percentage'] = \
|
||||
int((build_obj.repos_cloned /
|
||||
build_obj.repos_to_clone) * 100)
|
||||
else:
|
||||
build['repos_cloned_percentage'] = 0
|
||||
|
||||
tasks_complete_percentage = 0
|
||||
if build_obj.outcome in (Build.SUCCEEDED, Build.FAILED):
|
||||
|
||||
Reference in New Issue
Block a user