:s: size
    :factor: 1000 or 1024

def human_size(s, factor):
    """
    :s: size
    :factor: 1000 or 1024
    """
    unit = 'B'
    if s > factor:
        s /= factor
        unit = 'KB'
    if s > factor:
        s /= factor
        unit = 'MB'
    if s > factor:
        s /= factor
        unit = 'GB'
    if s > factor:
        s /= factor
        unit = 'TB'
    return '%.2f %s' % (s, unit)