Accept some number of bits/sec (i.e., a link capacity) as an
    integer, and return a string representing a 'human'(-like)
    representation of the capacity, e.g., 10 Mb/s, 1.5 Mb/s,
    900 Gb/s.

    As is the standard in networking, capacity values are assumed
    to be base-10 values (not base 2), so 1000 is 1 Kb/s.

def humanize_bandwidth(bits):
    '''
    Accept some number of bits/sec (i.e., a link capacity) as an
    integer, and return a string representing a 'human'(-like)
    representation of the capacity, e.g., 10 Mb/s, 1.5 Mb/s,
    900 Gb/s.

    As is the standard in networking, capacity values are assumed
    to be base-10 values (not base 2), so 1000 is 1 Kb/s.
    '''
    unit = ''
    divisor = 1
    if bits < 1000:
        unit = 'bits'
        divisor = 1
    elif bits < 1000000:
        unit = 'Kb'
        divisor = 1000
    elif bits < 1000000000:
        unit = 'Mb'
        divisor = 1000000
    elif bits < 1000000000000:
        unit = 'Gb'
        divisor = 1000000000
    elif bits < 1000000000000000:
        unit = 'Tb'
        divisor = 1000000000000
    else:
        raise Exception("Can't humanize that many bits.")

    if bits % divisor == 0:
        value = int(bits/divisor)
    else:
        value = bits/divisor

    return "{} {}/s".format(value, unit)