Added fixes to foreignkeys select in webmodel and added filesize.py module

This commit is contained in:
Antonio de la Rosa 2016-08-23 05:25:51 +02:00
parent 617a9fb87b
commit dfe0ee6550
2 changed files with 34 additions and 6 deletions

View file

@ -0,0 +1,14 @@
#!/usr/bin/python3
# Code based in http://stackoverflow.com/questions/5194057/better-way-to-convert-file-sizes-in-python
import math
def filesize(size):
if (size == 0):
return '0B'
size_name = ("b", "Kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb")
i = int(math.floor(math.log(size,1024)))
p = math.pow(1024,i)
s = round(size/p,2)
return '%s %s' % (s,size_name[i])