[oe-commits] Ed Bartosh : wic: round variable before converting to int

git at git.openembedded.org git at git.openembedded.org
Wed Sep 9 13:53:08 UTC 2015


Module: openembedded-core.git
Branch: master
Commit: 3479e299b5f11dfcd3f5f97c4ad3e0449f6c6d6a
URL:    http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=3479e299b5f11dfcd3f5f97c4ad3e0449f6c6d6a

Author: Ed Bartosh <ed.bartosh at linux.intel.com>
Date:   Mon Sep  7 13:01:13 2015 +0300

wic: round variable before converting to int

Wic uses bitbake variable ROOTFS_SIZE to set correspondent
partition size. This variable is a literal representing
float value. Wic crashes trying to convert it to int with
the error: invalid literal for int() with base 10: '10166.0'

Fixed this by converting variable to float and rounding result.
This should work for int and float literals.

Signed-off-by: Ed Bartosh <ed.bartosh at linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>

---

 scripts/lib/wic/imager/direct.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/lib/wic/imager/direct.py b/scripts/lib/wic/imager/direct.py
index 31c0edc..146a0d1 100644
--- a/scripts/lib/wic/imager/direct.py
+++ b/scripts/lib/wic/imager/direct.py
@@ -242,7 +242,7 @@ class DirectImageCreator(BaseImageCreator):
                     rsize_bb = get_bitbake_var('ROOTFS_SIZE', image_name)
                     if rsize_bb:
                         # convert from Kb to Mb
-                        part.size = int(rsize_bb) / 1024
+                        part.size = int(round(float(rsize_bb) / 1024.))
             # need to create the filesystems in order to get their
             # sizes before we can add them and do the layout.
             # Image.create() actually calls __format_disks() to create



More information about the Openembedded-commits mailing list