Esempio n. 1
0
def test_ram():
	expect = [
		{
			"type": "ram",
			"working": "yes",
			"brand": "Kingston",
			"model": "K",
			"sn": "3375612238",
			"frequency-hertz": 667000000,
			"capacity-byte": 2147483648,
			"ram-type": "ddr2",
			"ram-ecc": "yes",
			"ram-timings": "5-5-5-15"
		},
		{
			"type": "ram",
			"working": "yes",
			"brand": "Kingston",
			"model": "K",
			"sn": "3392385358",
			"frequency-hertz": 667000000,
			"capacity-byte": 2147483648,
			"ram-type": "ddr2",
			"ram-ecc": "yes",
			"ram-timings": "5-5-5-15"
		}
	]
	output = read_decode_dimms.read_decode_dimms(os.path.join(filedir, 'dimms.txt'))

	assert output == expect
Esempio n. 2
0
def extract_data(directory: str,
                 has_dedicated_gpu: bool,
                 gpu_in_cpu: bool,
                 cleanup: bool,
                 verbose: bool,
                 unpack: bool = True):
    mobo = get_baseboard(directory + "/baseboard.txt")
    cpu = read_lscpu(directory + "/lscpu.txt")
    gpu = read_lspci_and_glxinfo(has_dedicated_gpu, directory + "/lspci.txt",
                                 directory + "/glxinfo.txt", verbose)
    if not has_dedicated_gpu:
        entries = extract_integrated_gpu_from_standalone(gpu)
        if gpu_in_cpu:
            if isinstance(cpu, list):
                # Multiple processors
                updated_cpus = []
                for one_cpu in cpu:
                    one_cpu = {**one_cpu, **entries}
                    updated_cpus.append(one_cpu)
                cpu = updated_cpus
                del updated_cpus
            else:
                cpu = {**cpu, **entries}
        else:
            mobo = {**mobo, **entries}
        gpu = []
    mobo = get_connectors(directory + "/connector.txt", mobo, verbose)
    mobo = get_net(directory + "/net.txt", mobo, verbose)
    chassis = get_chassis(directory + "/chassis.txt")
    dimms = read_decode_dimms(directory + "/dimms.txt", verbose)
    if chassis["motherboard-form-factor"] == "proprietary-laptop":
        psu = {"type": "external-psu"}
    else:
        psu = {"type": "psu"}
    disks = read_smartctl(directory)

    result = []
    empty_dict = {}
    for component in (chassis, mobo, cpu, dimms, gpu, disks, psu):
        # return JSON ready for TARALLO
        if unpack:
            if isinstance(component, list):
                if component.__len__() == 0:
                    result.append(empty_dict)
                    continue
                for item in component:
                    result.append(item)
            else:
                result.append(component)
        # return list of lists of dicts to use in extract_and_collect_data_from_generated_files() for long output
        else:
            if component.__len__() == 0:
                result.append(empty_dict)
            else:
                result.append(component)

    if cleanup:
        result = do_cleanup(result, verbose)

    return result
Esempio n. 3
0
def test_ecc_ram1_not_an_hex():
	expect = [
		{
			"type": "ram",
			"working": "yes",
			"brand": "Kingston",
			"model": "K",
			"sn": "0F00xb4r",
			"frequency-hertz": 667000000,
			"capacity-byte": 2147483648,
			"ram-type": "ddr2",
			"ram-ecc": "yes",
			"ram-timings": "5-5-5-15"
		},
		{
			"type": "ram",
			"working": "yes",
			"brand": "Kingston",
			"model": "K",
			"sn": "0xCA33B3RC",
			"frequency-hertz": 667000000,
			"capacity-byte": 2147483648,
			"ram-type": "ddr2",
			"ram-ecc": "yes",
			"ram-timings": "5-5-5-15"
		}
	]
	output = read_decode_dimms.read_decode_dimms(os.path.join(filedir, 'ECC/R451-R450-notanhex.txt'))

	assert output == expect
Esempio n. 4
0
def test_ecc_ram2():
	expect = [
		{
			"type": "ram",
			"working": "yes",
			"brand": "Kingston",
			"model": "Undefined",
			"sn": "2853609420",
			"frequency-hertz": 667000000,
			"capacity-byte": 1073741824,
			"ram-type": "ddr2",
			"ram-ecc": "yes",
			"ram-timings": "5-5-5-15"
		},
		{
			"type": "ram",
			"working": "yes",
			"brand": "Kingston",
			"model": "Undefined",
			"sn": "2836829644",
			"frequency-hertz": 667000000,
			"capacity-byte": 1073741824,
			"ram-type": "ddr2",
			"ram-ecc": "yes",
			"ram-timings": "5-5-5-15"
		}

	]
	output = read_decode_dimms.read_decode_dimms(os.path.join(filedir, 'ECC/R480-R479.txt'))

	assert output == expect
Esempio n. 5
0
def test_ram():
    expect = [{
        "type": "ram",
        "working": "yes",
        "brand": "Synertek",
        "model": "Undefined",
        "sn": "",
        "frequency-hertz": -1,
        "capacity-byte": -1,
        "ram-type": "",
        "ram-ecc": "no",
        "ram-timings": ""
    }, {
        "type": "ram",
        "working": "yes",
        "brand": "Synertek",
        "model": "Undefined",
        "sn": "",
        "frequency-hertz": -1,
        "capacity-byte": -1,
        "ram-type": "",
        "ram-ecc": "no",
        "ram-timings": ""
    }]
    output = read_decode_dimms.read_decode_dimms(
        os.path.join(filedir, 'dimms.txt'))

    assert len(output) == 2, "2 RAM modules are found"
    assert output == expect
Esempio n. 6
0
def test_ecc_ram1():
    expect = [{
        "type": "ram",
        "working": "yes",
        "brand": "Kingston",
        "model": "K",
        "sn": "3375612524",
        "frequency-hertz": 667000000,
        "human_readable_frequency": "666 MHz",
        "capacity-byte": 2147483648,
        "human_readable_capacity": "2048 MB",
        "ram-type": "ddr2",
        "ram-ecc": "yes",
        "ram-timings": "5-5-5-15"
    }, {
        "type": "ram",
        "working": "yes",
        "brand": "Kingston",
        "model": "K",
        "sn": "3392385900",
        "frequency-hertz": 667000000,
        "human_readable_frequency": "666 MHz",
        "capacity-byte": 2147483648,
        "human_readable_capacity": "2048 MB",
        "ram-type": "ddr2",
        "ram-ecc": "yes",
        "ram-timings": "5-5-5-15"
    }]
    output = read_decode_dimms.read_decode_dimms(
        os.path.join(filedir, 'ECC/R451-R450.txt'))

    assert output == expect
Esempio n. 7
0
def test_ram():
    expect = [{
        'ram-ecc': 'no',
        'ram-type': 'ddr3',
        'brand': 'G Skill Intl',
        'capacity-byte': 8589934592,
        'frequency-hertz': 1333000000,
        'model': 'F3-1600C7-8GTX',
        'sn': '',
        'type': 'ram',
        "working": "yes",
        'ram-timings': '9-9-9-24',
    }, {
        'ram-ecc': 'no',
        'ram-type': 'ddr3',
        'brand': 'G Skill Intl',
        'capacity-byte': 8589934592,
        'frequency-hertz': 1333000000,
        'model': 'F3-1600C7-8GTX',
        'sn': '',
        'type': 'ram',
        "working": "yes",
        'ram-timings': '9-9-9-24',
    }]
    output = read_decode_dimms.read_decode_dimms(
        os.path.join(filedir, 'dimms.txt'))

    assert len(output) == 2, "2 RAM modules are found"
    assert output == expect
Esempio n. 8
0
def test_ram():
    expect = [{
        'brand': 'Micron Technology',
        'capacity-byte': 8589934592,
        'frequency-hertz': 1600000000,
        'model': 'CT102464BA160B.C16',
        'ram-ecc': 'no',
        'ram-timings': '11-11-11-28',
        'ram-type': 'ddr3',
        'sn': '1949761536',
        'type': 'ram',
        'working': 'yes',
    }, {
        'brand': 'Micron Technology',
        'capacity-byte': 8589934592,
        'frequency-hertz': 1600000000,
        'model': 'CT102464BA160B.C16',
        'ram-ecc': 'no',
        'ram-timings': '11-11-11-28',
        'ram-type': 'ddr3',
        'sn': '2172780544',
        'type': 'ram',
        'working': 'yes',
    }]
    output = read_decode_dimms.read_decode_dimms(
        os.path.join(filedir, 'dimms.txt'))

    assert len(output) == 2, "2 RAM modules are found"
    assert output == expect
Esempio n. 9
0
def test_ram():
    expect = [{
        "type": "ram",
        "working": "yes",
        "brand": "Kingston",
        "model": "K",
        "sn": "3375612238",
        "frequency-hertz": 667000000,
        "human_readable_frequency": "666 MHz",
        "capacity-byte": 2147483648,
        "human_readable_capacity": "2048 MB",
        "ram-type": "ddr2",
        "ram-ecc": "yes",
        "ram-timings": "5-5-5-15"
    }, {
        "type": "ram",
        "working": "yes",
        "brand": "Kingston",
        "model": "K",
        "sn": "3392385358",
        "frequency-hertz": 667000000,
        "human_readable_frequency": "666 MHz",
        "capacity-byte": 2147483648,
        "human_readable_capacity": "2048 MB",
        "ram-type": "ddr2",
        "ram-ecc": "yes",
        "ram-timings": "5-5-5-15"
    }]
    output = read_decode_dimms.read_decode_dimms(filedir + 'dimms.txt')

    assert output == expect
Esempio n. 10
0
def test_ram1():
    expect = [{
        "type": "ram",
        "working": "yes",
        "brand": "SK Hynix (former Hyundai Electronics)",
        "model": "HYMP112U64CP8-S6",
        "sn": "16416",
        "frequency-hertz": 800000000,
        "human_readable_frequency": "800 MHz",
        "capacity-byte": 1073741824,
        "human_readable_capacity": "1024 MB",
        "ram-type": "ddr2",
        "ram-ecc": "no",
        "ram-timings": "6-6-6-18"
    }, {
        "type": "ram",
        "working": "yes",
        "brand": "SK Hynix (former Hyundai Electronics)",
        "model": "HYMP112U64CP8-S6",
        "sn": "8224",
        "frequency-hertz": 800000000,
        "human_readable_frequency": "800 MHz",
        "capacity-byte": 1073741824,
        "human_readable_capacity": "1024 MB",
        "ram-type": "ddr2",
        "ram-ecc": "no",
        "ram-timings": "6-6-6-18"
    }, {
        "type": "ram",
        "working": "yes",
        "brand": "SK Hynix (former Hyundai Electronics)",
        "model": "HYMP112U64CP8-S6",
        "sn": "12320",
        "frequency-hertz": 800000000,
        "human_readable_frequency": "800 MHz",
        "capacity-byte": 1073741824,
        "human_readable_capacity": "1024 MB",
        "ram-type": "ddr2",
        "ram-ecc": "no",
        "ram-timings": "6-6-6-18"
    }, {
        "type": "ram",
        "working": "yes",
        "brand": "SK Hynix (former Hyundai Electronics)",
        "model": "HYMP112U64CP8-S6",
        "sn": "8225",
        "frequency-hertz": 800000000,
        "human_readable_frequency": "800 MHz",
        "capacity-byte": 1073741824,
        "human_readable_capacity": "1024 MB",
        "ram-type": "ddr2",
        "ram-ecc": "no",
        "ram-timings": "6-6-6-18"
    }]
    output = read_decode_dimms.read_decode_dimms(
        os.path.join(filedir, 'non ECC/R469-R470-R471-R472.txt'))

    assert output == expect
Esempio n. 11
0
def test_ram():
    expect = [{
        "type": "ram",
        "working": "yes",
        "brand": "Kingston",
        "model": "Undefined",
        "sn": "2972574626",
        "frequency-hertz": 533000000,
        "capacity-byte": 536870912,
        "ram-type": "ddr2",
        "ram-ecc": "no",
        "ram-timings": "5-4-4-12"
    }]
    output = read_decode_dimms.read_decode_dimms(
        os.path.join(filedir, 'dimms.txt'))

    assert output == expect
Esempio n. 12
0
def test_ram():
    expect = [{
        "type": "ram",
        "working": "yes",
        "brand": "Kingston",
        "model": "KD6502-ELG",
        "sn": "3072778780",
        "frequency-hertz": 667000000,
        "human_readable_frequency": "666 MHz",
        "capacity-byte": 1073741824,
        "human_readable_capacity": "1024 MB",
        "ram-type": "ddr2",
        "ram-ecc": "yes",
        "ram-timings": "5-5-5-15"
    }]
    output = read_decode_dimms.read_decode_dimms(filedir + 'dimms.txt')

    assert output == expect
Esempio n. 13
0
def test_ram():
	expect = [
		{
			"type": "ram",
			"working": "yes",
			"brand": "Kingston",
			"model": "KD6502-ELG",
			"sn": "3072778780",
			"frequency-hertz": 667000000,
			"capacity-byte": 1073741824,
			"ram-type": "ddr2",
			"ram-ecc": "yes",
			"ram-timings": "5-5-5-15"
		}
	]
	output = read_decode_dimms.read_decode_dimms(os.path.join(filedir, 'dimms.txt'))

	assert output == expect
Esempio n. 14
0
def test_ram():
    output = read_decode_dimms.read_decode_dimms(
        os.path.join(filedir, 'dimms.txt'))

    assert len(output) == 0
Esempio n. 15
0
def test_ram():
    output = read_decode_dimms.read_decode_dimms(filedir + 'dimms.txt')

    assert len(output) == 0
Esempio n. 16
0
def extract_data(directory: str,
                 has_dedicated_gpu: bool,
                 gpu_in_cpu: bool,
                 gui: bool,
                 verbose: bool,
                 unpack: bool = True):
    mobo = get_baseboard(directory + "/baseboard.txt")
    cpu = read_lscpu(directory + "/lscpu.txt")
    gpu = read_lspci_and_glxinfo(has_dedicated_gpu, directory + "/lspci.txt",
                                 directory + "/glxinfo.txt", verbose)
    if not has_dedicated_gpu:
        entries = extract_integrated_gpu_from_standalone(gpu)
        if gpu_in_cpu:
            if isinstance(cpu, list):
                # Multiple processors
                updated_cpus = []
                for one_cpu in cpu:
                    one_cpu = {**one_cpu, **entries}
                    updated_cpus.append(one_cpu)
                cpu = updated_cpus
                del updated_cpus
            else:
                cpu = {**cpu, **entries}
        else:
            mobo = {**mobo, **entries}
        gpu = []
    mobo = get_connectors(directory + "/connector.txt", mobo, verbose)
    mobo = get_net(directory + "/net.txt", mobo, verbose)
    chassis = get_chassis(directory + "/chassis.txt")
    dimms = read_decode_dimms(directory + "/dimms.txt", verbose)
    if chassis["motherboard-form-factor"] == "proprietary-laptop":
        psu = {"type": "external-psu"}
    else:
        psu = {"type": "psu"}
    disks = read_smartctl(directory)

    result = []
    empty_dict = {}
    for component in (chassis, mobo, cpu, dimms, gpu, disks, psu):
        # return JSON ready for TARALLO
        if unpack:
            if isinstance(component, list):
                if len(component) == 0:
                    result.append(empty_dict)
                    continue
                for item in component:
                    result.append(item)
            else:
                result.append(component)
        # return list of lists of dicts to use in extract_and_collect_data_from_generated_files() for long output
        else:
            if len(component) == 0:
                result.append(empty_dict)
            else:
                result.append(component)

        result = do_cleanup(result, gui, verbose)

    # check on case and mobo
    try:
        if (chassis['model'], chassis['brand'],
                chassis['variant']) == (mobo['brand'], mobo['model'],
                                        mobo['variant']):
            chassis.pop('model')
    except KeyError:
        pass

    # maybe there's a nicer way
    comparator = []
    for comp in result:
        if isinstance(comp, list):
            comparator = comparator + comp
        else:
            comparator.append(comp)

    # avoid bad associations between items and products
    for comp1 in comparator:
        for comp2 in comparator:
            if is_product(comp1) and is_product(
                    comp2) and comp1['type'] != comp2['type']:
                if (comp1['brand'], comp2['model']) == (comp2['brand'],
                                                        comp2['model']):
                    variant1 = comp1.pop('variant', '')
                    variant2 = comp2.pop('variant', '')
                    if variant1 == variant2:
                        comp1['variant'] = variant1.rstrip().join(
                            f"_{comp1['type']}")
                        comp2['variant'] = variant2.rstrip().join(
                            f"_{comp2['type']}")
    return result