def test_net_with_connectors_too_many():
    baseboard = read_dmidecode.get_baseboard(
        os.path.join(filedir, 'baseboard.txt'))
    baseboard = read_dmidecode.get_connectors(
        os.path.join(filedir, 'connector.txt'), baseboard)

    expect = {
        "type": "motherboard",
        "working": "yes",
        "brand": "ASUSTeK Computer INC.",
        "model": "P6T DELUXE V2",
        "sn": "723627130020069",
        "ps2-ports-n": 1,
        "usb-ports-n": 7,
        'firewire-ports-n': 3,
        'ide-ports-n': 1,
        'sata-ports-n': 6,
        "mini-jack-ports-n": 7,
        'ethernet-ports-1000m-n': 3,
        'mac': '00:c0:11:fe:fe:11, 00:c0:11:fe:fe:22, 00:c0:11:fe:fe:42',
        'sas-sata-ports-n': 2,
        'notes': 'Unknown connector: None / Other (AUDIO / AUDIO)'
    }
    output = read_dmidecode.get_net(os.path.join(filedir, 'net_too_many.txt'),
                                    baseboard)

    assert output == expect
Exemple #2
0
def test_connector():
    baseboard = read_dmidecode.get_baseboard(filedir + 'baseboard.txt')

    expect = {
        "type": "motherboard",
        "working": "yes",
        "brand": "ASUSTeK Computer INC.",
        "model": "P5VD2-VM",
        "sn": "123456789000",
        "serial-ports-n": 1,
        "parallel-ports-n": 1,
        "usb-ports-n": 8,
        "ps2-ports-n": 2,
        "sata-ports-n": 3,
        "esata-ports-n": 1,
        "vga-ports-n": 1,
        "ethernet-ports-n": 1,
        "mini-jack-ports-n": 3,
        "ide-ports-n": 2,
        "notes": "Unknown connector: None / None (SPDIF_OUT / SPDIF_OUT)"
    }
    output = read_dmidecode.get_connectors(filedir + 'connector.txt',
                                           baseboard)

    assert output == expect
Exemple #3
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
def test_baseboard():
    expect = {
        'type': 'motherboard',
        "working": "yes",
        'brand': 'Apple Inc.',
        'model': 'Mac-937A206F2EE63C01',
        'sn': 'C0290440002JP5P1T'
    }
    output = read_dmidecode.get_baseboard(filedir + 'baseboard.txt')

    assert output == expect
def test_baseboard():
    expect = {
        'type': 'motherboard',
        "working": "yes",
        'brand': 'Apple Inc.',
        'model': 'Mac-2BD1B31983FE1663',
        'sn': 'C02433601ECG3MK13'
    }
    output = read_dmidecode.get_baseboard(filedir + 'baseboard.txt')

    assert output == expect
Exemple #6
0
def test_baseboard():
    expect = {
        "type": "motherboard",
        "working": "yes",
        "brand": "LENOVO",
        "model": "2718V8C",
        "sn": "VQ1FF05G1WA",
    }
    output = read_dmidecode.get_baseboard(filedir + 'baseboard.txt')

    assert output == expect
Exemple #7
0
def test_77_baseboard():
	expect = {
		'brand': 'ASUSTeK Computer INC.',
		'model': 'P5SD2-VM',
		'sn': 'MT721CT11114269',
		'type': 'motherboard',
		"working": "yes",
	}
	output = read_dmidecode.get_baseboard(os.path.join(filedir, 'baseboard.txt'))

	assert output == expect
Exemple #8
0
def test_baseboard():
    expect = {
        "type": "motherboard",
        "working": "yes",
        "brand": "Hewlett-Packard",
        "model": "09F8h",
        "sn": "CZC6203MC5",
    }
    output = read_dmidecode.get_baseboard(filedir + 'baseboard.txt')

    assert output == expect
Exemple #9
0
def test_baseboard():
	expect = {
		"type": "motherboard",
		"working": "yes",
		"brand": "ASUSTeK Computer INC.",
		"model": "P5QL-E",
		"sn": "MS666999ABCDEF123",
	}
	output = read_dmidecode.get_baseboard(filedir + 'baseboard.txt')

	assert output == expect
Exemple #10
0
def test_baseboard():
	expect = {
		"type": "motherboard",
		"working": "yes",
		"brand": "ASRock",
		"model": "H110M-ITX/ac",
		"sn": "M80-69017400518",
	}
	output = read_dmidecode.get_baseboard(os.path.join(filedir, 'baseboard.txt'))

	assert output == expect
def test_baseboard():
	expect = {
		"type": "motherboard",
		"working": "yes",
		"brand": "Microsoft Corporation",
		"model": "Surface Pro 4",
		"sn": "A01012111654643A",
	}
	output = read_dmidecode.get_baseboard(os.path.join(filedir, 'baseboard.txt'))

	assert output == expect
Exemple #12
0
def test_baseboard():
    expect = {
        "type": "motherboard",
        "working": "yes",
        "brand": "ASUSTeK Computer INC.",
        "model": "P5VD2-VM",
        "sn": "123456789000",
    }
    output = read_dmidecode.get_baseboard(filedir + 'baseboard.txt')

    assert output == expect
Exemple #13
0
def test_baseboard():
	expect = {
		"type": "motherboard",
		"working": "yes",
		"brand": "ASUSTeK Computer INC.",
		"model": "P5V-VM-ULTRA",
		"sn": "MB-1234567890",
	}
	output = read_dmidecode.get_baseboard(os.path.join(filedir, 'baseboard.txt'))

	assert output == expect
Exemple #14
0
def test_baseboard():
    expect = {
        "type": "motherboard",
        "working": "yes",
        "brand": "LENOVO",
        "model": "246837G",
        "sn": "2RTC1A0N333",
    }
    output = read_dmidecode.get_baseboard(filedir + 'baseboard.txt')

    assert output == expect
Exemple #15
0
def test_baseboard():
    expect = {
        'type': 'motherboard',
        "working": "yes",
        'brand': 'ASUSTeK COMPUTER INC.',
        'model': 'UX305CA',
        'sn': 'BSN12345678901234567'
    }
    output = read_dmidecode.get_baseboard(filedir + 'baseboard.txt')

    assert output == expect
def test_baseboard():
	expect = {
		"type": "motherboard",
		"working": "yes",
		"brand": "Intel Corporation",
		"model": "D975XBX2",
		"sn": "BAOB4B9001YY",
	}
	output = read_dmidecode.get_baseboard(os.path.join(filedir, 'baseboard.txt'))

	assert output == expect
Exemple #17
0
def test_baseboard():
    expect = {
        'brand': 'Gigabyte Technology Co., Ltd.',
        'model': '970A-DS3P FX',
        'sn': 'To be filled by O.E.M.',
        'type': 'motherboard',
        "working": "yes",
    }
    output = read_dmidecode.get_baseboard(filedir + 'baseboard.txt')

    assert output == expect
Exemple #18
0
def test_baseboard():
    expect = {
        "type": "motherboard",
        "working": "yes",
        "brand": "Matsonic",
        "model": "MS8318E",
        "sn": "00000000",
    }
    output = read_dmidecode.get_baseboard(filedir + 'baseboard.txt')

    assert output == expect
Exemple #19
0
def test_baseboard():
    expect = {
        "type": "motherboard",
        "working": "yes",
        "brand": "Dell Inc.",
        "model": "0MY171",
        "sn": "CN125321L404Q",
    }
    output = read_dmidecode.get_baseboard(filedir + 'baseboard.txt')

    assert output == expect
Exemple #20
0
def test_baseboard():
	expect = {
		"type": "motherboard",
		"working": "yes",
		"brand": "ASUSTeK Computer INC.",
		"model": "P6T DELUXE V2",
		"sn": "723627130020069",
	}
	output = read_dmidecode.get_baseboard(filedir + 'baseboard.txt')

	assert output == expect
Exemple #21
0
def test_baseboard():
    expect = {
        'brand': 'ASUSTeK Computer INC.',
        'model': 'P8H67-M LE',
        'sn': 'A5D10110N3',
        'type': 'motherboard',
        'working': 'yes',
    }
    output = read_dmidecode.get_baseboard(
        os.path.join(filedir, 'baseboard.txt'))

    assert output == expect
Exemple #22
0
def test_connector():
    baseboard = read_dmidecode.get_baseboard(filedir + 'baseboard.txt')

    expect = {
        "type": "motherboard",
        "working": "yes",
        "brand": "Microsoft Corporation",
        "model": "Surface Pro 4",
        "sn": "A01012111654643A",
        "notes": ""
    }
    output = read_dmidecode.get_connectors(filedir + 'connector.txt',
                                           baseboard)

    assert output == expect
def test_connector():
	baseboard = read_dmidecode.get_baseboard(os.path.join(filedir, 'baseboard.txt'))

	expect = {
		"type": "motherboard",
		"working": "yes",
		"brand": "Intel Corporation",
		"model": "D975XBX2",
		"sn": "BAOB4B9001YY",
		"ide-ports-n": 2,
		"notes": ""
	}
	output = read_dmidecode.get_connectors(os.path.join(filedir, 'connector.txt'), baseboard)

	assert output == expect
Exemple #24
0
def test_connector():
	baseboard = read_dmidecode.get_baseboard(os.path.join(filedir, 'baseboard.txt'))

	# Yep, the connector thing is empty...
	expect = {
		'type': 'motherboard',
		"working": "yes",
		'brand': 'ASUSTeK COMPUTER INC.',
		'model': 'UX305CA',
		'sn': 'BSN12345678901234567',
		'notes': ''
	}
	output = read_dmidecode.get_connectors(os.path.join(filedir, 'connector.txt'), baseboard)

	assert output == expect
Exemple #25
0
def test_net_without_connectors():
	baseboard = read_dmidecode.get_baseboard(filedir + 'baseboard.txt')

	expect = {
		"type": "motherboard",
		"working": "yes",
		"brand": "ASUSTeK Computer INC.",
		"model": "P6T DELUXE V2",
		"sn": "723627130020069",
		'ethernet-ports-1000m-n': 2,
		'mac': '00:c0:11:fe:fe:11, 00:c0:11:fe:fe:22',
	}
	output = read_dmidecode.get_net(filedir + 'net.txt', baseboard)

	assert output == expect
Exemple #26
0
def test_connector():
	baseboard = read_dmidecode.get_baseboard(os.path.join(filedir, 'baseboard.txt'))

	# This is entirely wrong and is not reflected by any means from reality and the real motherboard, but the manufacturer
	# dropped all this garbage into the DMI information, so here we go...
	expect = {
		"type": "motherboard",
		"working": "yes",
		"brand": "ASRock",
		"model": "H110M-ITX/ac",
		"sn": "M80-69017400518",
		"notes": ""
	}
	output = read_dmidecode.get_connectors(os.path.join(filedir, 'connector.txt'), baseboard)

	assert output == expect
Exemple #27
0
def test_connector():
    baseboard = read_dmidecode.get_baseboard(filedir + 'baseboard.txt')

    expect = {
        "type": "motherboard",
        "working": "yes",
        "brand": "Matsonic",
        "model": "MS8318E",
        "sn": "00000000",
        "parallel-ports-n": 1,
        "notes": ""
    }

    output = read_dmidecode.get_connectors(filedir + 'connector.txt',
                                           baseboard)

    assert output == expect
Exemple #28
0
def test_connector():
    baseboard = read_dmidecode.get_baseboard(
        os.path.join(filedir, 'baseboard.txt'))

    # This is entirely wrong and is not reflected by any means from reality and the real motherboard, but the manufacturer
    # dropped all this garbage into the DMI information, so here we go...
    expect = {
        'brand':
        'Gigabyte Technology Co., Ltd.',
        'model':
        '970A-DS3P FX',
        'sn':
        'To be filled by O.E.M.',
        'type':
        'motherboard',
        "working":
        "yes",
        'usb-ports-n':
        3,
        'ps2-ports-n':
        2,
        'vga-ports-n':
        1,
        'serial-ports-n':
        1,
        'notes':
        'Unknown connector: None / Mini Centronics Type-14 (J2A1 / TV Out)\n'
        'Unknown connector: Other / None (J9A1 - TPM HDR / Not Specified)\n'
        'Unknown connector: Other / None (J9C1 - PCIE DOCKING CONN / Not Specified)\n'
        'Unknown connector: Other / None (J6C2 - EXT HDMI / Not Specified)\n'
        'Unknown connector: Other / None (J1D1 - ITP / Not Specified)\n'
        'Unknown connector: Other / None (J9E2 - MDC INTPSR / Not Specified)\n'
        'Unknown connector: Other / None (J9E4 - MDC INTPSR / Not Specified)\n'
        'Unknown connector: Other / None (J9E3 - LPC HOT DOCKING / Not Specified)\n'
        'Unknown connector: Other / None (J9E1 - SCAN MATRIX / Not Specified)\n'
        'Unknown connector: Other / None (J9G1 - LPC SIDE BAND / Not Specified)\n'
        'Unknown connector: Other / None (J8F1 - UNIFIED / Not Specified)\n'
        'Unknown connector: Other / None (J6F1 - LVDS / Not Specified)\n'
        'Unknown connector: Other / None (J2G1 - GFX VID / Not Specified)\n'
        'Unknown connector: Other / None (J1G6 - AC JACK / Not Specified)',
    }
    output = read_dmidecode.get_connectors(
        os.path.join(filedir, 'connector.txt'), baseboard)

    assert output == expect
def test_connector():
    baseboard = read_dmidecode.get_baseboard(filedir + 'baseboard.txt')

    expect = {
        'type': 'motherboard',
        "working": "yes",
        'brand': 'Apple Inc.',
        'model': 'Mac-937A206F2EE63C01',
        'sn': 'C0290440002JP5P1T',
        'usb-ports-n': 2,
        'mini-jack-ports-n': 1,
        'thunderbolt-ports-n': 1,
        'notes': '',
    }
    output = read_dmidecode.get_connectors(filedir + 'connector.txt',
                                           baseboard)

    assert output == expect
Exemple #30
0
def test_connector():
    baseboard = read_dmidecode.get_baseboard(filedir + 'baseboard.txt')

    expect = {
        "type": "motherboard",
        "working": "yes",
        "brand": "LENOVO",
        "model": "246837G",
        "sn": "2RTC1A0N333",
        "usb-ports-n": 4,
        "vga-ports-n": 1,
        "mini-jack-ports-n": 1,
        "ethernet-ports-n": 1,
        "mini-displayport-ports-n": 1,
        "notes": "",
    }
    output = read_dmidecode.get_connectors(filedir + 'connector.txt',
                                           baseboard)

    assert output == expect