Make image sizes more readable for humans

By introducing the parameter --human-readable for several functions
(image-list, image-show, image-update, image-create) it's possible
to convert the size in bytes to something more readable like
9.309MB or 1.375GB.

Change-Id: I4e2654994361dcf330ed6d681dbed73388f159cb
This commit is contained in:
Christian Berendt
2012-11-07 19:39:43 +01:00
committed by Brian Waldon
parent 16aafa728e
commit b24832c22a
3 changed files with 39 additions and 4 deletions
+5
View File
@@ -43,3 +43,8 @@ class TestUtils(unittest.TestCase):
fixture = 'CCC'
checksum = 'defb99e69a9f1f6e06f15006b1f166ae'
data = ''.join([f for f in utils.integrity_iter(fixture, checksum)])
def test_make_size_human_readable(self):
self.assertEqual("1024.000kB", utils.make_size_human_readable(1048576))
self.assertEqual("1.375GB", utils.make_size_human_readable(1476395008))
self.assertEqual("9.309MB", utils.make_size_human_readable(9761280))