check if size is 0 in human_size, avoid math domain error
authorGui Chen <gui.chen@intel.com>
Thu, 22 Mar 2012 08:59:34 +0000 (16:59 +0800)
committerGui Chen <gui.chen@intel.com>
Thu, 22 Mar 2012 08:59:34 +0000 (16:59 +0800)
Signed-off-by: Gui Chen <gui.chen@intel.com>
mic/utils/misc.py

index 636fffc..05d8a9a 100644 (file)
@@ -57,6 +57,8 @@ def human_size(size):
     """Return human readable string for Bytes size
     """
 
+    if size <= 0:
+        return "0M"
     import math
     measure = ['B', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']
     expo = int(math.log(size, 1024))