Merge ~jnavila/curtin:lvm_int_bytes into curtin:master

Proposed by Jean-Noël AVILA
Status: Needs review
Proposed branch: ~jnavila/curtin:lvm_int_bytes
Merge into: curtin:master
Diff against target: 22 lines (+2/-2)
1 file modified
curtin/util.py (+2/-2)
Reviewer Review Type Date Requested Status
curtin developers Pending
Review via email: mp+396875@code.launchpad.net

Description of the change

When using automatic install script in subiquity with automated size
computation, the output is a double with no decimal, but lvcreate
fails with values of bytes presenting a decimal point.

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

I think it would be better to fix subiquity to never put floats into the config file TBH.

~jnavila/curtin:lvm_int_bytes updated
26852cf... by Jean-Noël AVILA on 2021-01-26

Force human2bytes to always return an int

All sizes in bytes can only be integer. Moreover, for all users of
this function, the output can be printed without a decimal point
appearing.

Unmerged commits

26852cf... by Jean-Noël AVILA on 2021-01-26

Force human2bytes to always return an int

All sizes in bytes can only be integer. Moreover, for all users of
this function, the output can be printed without a decimal point
appearing.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/curtin/util.py b/curtin/util.py
2index be063d7..6f3f2d0 100644
3--- a/curtin/util.py
4+++ b/curtin/util.py
5@@ -990,7 +990,7 @@ def human2bytes(size):
6 if int(size) != size:
7 raise ValueError("'%s': resulted in non-integer (%s)" %
8 (size_in, int(size)))
9- return size
10+ return int(size)
11 elif not isinstance(size, str):
12 raise TypeError("cannot convert type %s ('%s')." % (type(size), size))
13
14@@ -1018,7 +1018,7 @@ def human2bytes(size):
15 if int(val) != val:
16 raise ValueError("'%s': resulted in non-integer (%s)" % (size_in, val))
17
18- return val
19+ return int(val)
20
21
22 def bytes2human(size):

Subscribers

People subscribed via source and target branches