Merge lp:~michaelh1/linaro-image-tools/fractional-partitions into lp:linaro-image-tools/11.11

Proposed by Michael Hope
Status: Rejected
Rejected by: James Tunnicliffe
Proposed branch: lp:~michaelh1/linaro-image-tools/fractional-partitions
Merge into: lp:linaro-image-tools/11.11
Diff against target: 21 lines (+2/-2)
1 file modified
linaro_image_tools/media_create/partitions.py (+2/-2)
To merge this branch: bzr merge lp:~michaelh1/linaro-image-tools/fractional-partitions
Reviewer Review Type Date Requested Status
Michael Hope (community) Needs Fixing
Данило Шеган (community) Needs Fixing
Review via email: mp+104666@code.launchpad.net

Description of the change

Support floating point image sizes such as --image-size 1.9G

To post a comment you must log in.
Revision history for this message
Данило Шеган (danilo) wrote :

Michael, thanks for working on this. This generally looks good, but please add a test for float values being passed in. Just add another test along the lines of test_convert_size_in_kbytes_to_bytes to
linaro_image_tools/media_create/tests/test_media_create.py that tests the new behavior.

Considering we are adding support for floats, one will also be able to say something like 1.0005K. What would you expect the proper behavior to be in that case? I'd expect 1001 bytes to be returned, so I'd also modify the return to round upwards, i.e.
  return int(real_size + 0.5)

(and add a test for this particular behavior as well).

It would also be good to file a bug for this feature request, so we can easily track what's going into the next release, so please do that as well.

review: Needs Fixing
Revision history for this message
Michael Hope (michaelh1) wrote :
review: Needs Fixing

Unmerged revisions

515. By Michael Hope

Support fractional partition sizes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'linaro_image_tools/media_create/partitions.py'
2--- linaro_image_tools/media_create/partitions.py 2012-04-18 14:18:34 +0000
3+++ linaro_image_tools/media_create/partitions.py 2012-05-04 04:36:18 +0000
4@@ -484,7 +484,7 @@
5 # no unit? (ends with a digit)
6 if unit in '0123456789':
7 return int(size)
8- real_size = int(size[:-1])
9+ real_size = float(size[:-1])
10 if unit == 'K':
11 real_size = real_size * 1024
12 elif unit == 'M':
13@@ -495,7 +495,7 @@
14 raise ValueError("Unknown size format: %s. Use K[bytes], M[bytes] "
15 "or G[bytes]" % size)
16
17- return real_size
18+ return int(real_size)
19
20
21 def run_sfdisk_commands(commands, heads, sectors, cylinders, device,

Subscribers

People subscribed via source and target branches