Пример #1
0
def test_parse_size():
    assert parse_size(None) == None
    assert parse_size('1') == 1
    assert parse_size('1024') == 1024
    assert parse_size('1k') == 1024
    assert parse_size('2k') == 1024 * 2
    assert parse_size('1m') == 1024 * 1024
    assert parse_size('1g') == 1024 * 1024 * 1024
    assert parse_size('1kb') == 1024
    assert parse_size('1kB') == 1024
    assert parse_size('1 kB') == 1024
Пример #2
0
def info():
    uname = os.uname()
    cpu = lscpu()
    mem = meminfo()
    return {
        'arch': uname.machine,
        'byte_order': sys.byteorder,
        'cpu_cache_L1d': parse_size(cpu.get('L1d cache')),
        'cpu_cache_L1i': parse_size(cpu.get('L1i cache')),
        'cpu_cache_L2': parse_size(cpu.get('L2 cache')),
        'cpu_cache_L3': parse_size(cpu.get('L3 cache')),
        'cpu_count': os.cpu_count(),
        'cpu_mhz': parse_float(cpu.get('CPU MHz')),
        'cpu_name': cpu.get('Model name'),
        'kernel': uname.sysname,
        'kernel_release': uname.release,
        'kernel_version': uname.version,
        'memory': parse_size(mem.get('MemTotal'))
    }