|
|
@ -143,10 +143,12 @@ class FileDownloader(object):
|
|
|
|
def format_bytes(bytes):
|
|
|
|
def format_bytes(bytes):
|
|
|
|
if bytes is None:
|
|
|
|
if bytes is None:
|
|
|
|
return 'N/A'
|
|
|
|
return 'N/A'
|
|
|
|
if bytes == 0:
|
|
|
|
if type(bytes) is str:
|
|
|
|
|
|
|
|
bytes = float(bytes)
|
|
|
|
|
|
|
|
if bytes == 0.0:
|
|
|
|
exponent = 0
|
|
|
|
exponent = 0
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
exponent = long(math.log(float(bytes), 1024.0))
|
|
|
|
exponent = long(math.log(bytes, 1024.0))
|
|
|
|
suffix = 'bkMGTPEZY'[exponent]
|
|
|
|
suffix = 'bkMGTPEZY'[exponent]
|
|
|
|
converted = float(bytes) / float(1024**exponent)
|
|
|
|
converted = float(bytes) / float(1024**exponent)
|
|
|
|
return '%.2f%s' % (converted, suffix)
|
|
|
|
return '%.2f%s' % (converted, suffix)
|
|
|
|