diff options
| author | Awais Belal <awais_belal@mentor.com> | 2018-08-26 15:33:27 -0700 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-08-28 10:32:08 +0100 |
| commit | 215c18771248ab71149b85d4aabd3e12b6409556 (patch) | |
| tree | 324630cb07132acb0b31f1621b8ba0b08bd354d2 /bitbake/lib | |
| parent | 525efc3a025d1bf3b9f20cb4342141f2be0b2079 (diff) | |
| download | poky-215c18771248ab71149b85d4aabd3e12b6409556.tar.gz | |
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: 679c70aa32d23e9247f8a68efcb579ad733af84b)
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>
Diffstat (limited to 'bitbake/lib')
| -rw-r--r-- | bitbake/lib/toaster/toastergui/widgets.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/bitbake/lib/toaster/toastergui/widgets.py b/bitbake/lib/toaster/toastergui/widgets.py index 88dff8a857..db5c3aa00b 100644 --- a/bitbake/lib/toaster/toastergui/widgets.py +++ b/bitbake/lib/toaster/toastergui/widgets.py | |||
| @@ -515,13 +515,18 @@ class MostRecentBuildsView(View): | |||
| 515 | buildrequest_id = build_obj.buildrequest.pk | 515 | buildrequest_id = build_obj.buildrequest.pk |
| 516 | build['buildrequest_id'] = buildrequest_id | 516 | build['buildrequest_id'] = buildrequest_id |
| 517 | 517 | ||
| 518 | build['recipes_parsed_percentage'] = \ | 518 | if build_obj.recipes_to_parse > 0: |
| 519 | int((build_obj.recipes_parsed / | 519 | build['recipes_parsed_percentage'] = \ |
| 520 | build_obj.recipes_to_parse) * 100) | 520 | int((build_obj.recipes_parsed / |
| 521 | 521 | build_obj.recipes_to_parse) * 100) | |
| 522 | build['repos_cloned_percentage'] = \ | 522 | else: |
| 523 | int((build_obj.repos_cloned / | 523 | build['recipes_parsed_percentage'] = 0 |
| 524 | build_obj.repos_to_clone) * 100) | 524 | if build_obj.repos_to_clone > 0: |
| 525 | build['repos_cloned_percentage'] = \ | ||
| 526 | int((build_obj.repos_cloned / | ||
| 527 | build_obj.repos_to_clone) * 100) | ||
| 528 | else: | ||
| 529 | build['repos_cloned_percentage'] = 0 | ||
| 525 | 530 | ||
| 526 | build['progress_item'] = build_obj.progress_item | 531 | build['progress_item'] = build_obj.progress_item |
| 527 | 532 | ||
