Exemplo n.º 1
0
def test_connector():
    baseboard = read_dmidecode.get_baseboard(
        os.path.join(filedir, 'baseboard.txt'))

    expect = {
        "type": "motherboard",
        "working": "yes",
        "brand": "Hewlett-Packard",
        "model": "09F8h",
        "sn": "CZC6203MC5",
        "ps2-ports-n": 2,
        "usb-ports-n": 8,
        "serial-ports-n": 2,
        "ethernet-ports-n": 1,
        'mini-jack-ports-n': 2,  # Probably wrong, but oh well...
        "ide-ports-n": 1,
        'parallel-ports-n': 1,
        'sata-ports-n': 2,
        'vga-ports-n': 1,
        "notes": ""
    }
    output = read_dmidecode.get_connectors(
        os.path.join(filedir, 'connector.txt'), baseboard)

    assert output == expect
Exemplo n.º 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
Exemplo n.º 3
0
def test_connector():
    baseboard = read_dmidecode.get_baseboard(
        os.path.join(filedir, 'baseboard.txt'))

    expect = {
        "type": "motherboard",
        "working": "yes",
        "brand": "ASUSTeK Computer INC.",
        "model": "P5QL-E",
        "sn": "MS666999ABCDEF123",
        "ps2-ports-n": 2,
        "usb-ports-n": 6,
        "serial-ports-n": 1,
        "mini-jack-ports-n": 1,
        "ethernet-ports-n": 1,
        "ide-ports-n": 1,
        "sata-ports-n": 6,
        'esata-ports-n': 1,
        "firewire-ports-n": 2,
        "notes": "Unknown connector: None / Other (AUDIO / AUDIO)"
    }
    output = read_dmidecode.get_connectors(
        os.path.join(filedir, 'connector.txt'), baseboard)

    assert output == expect
Exemplo n.º 4
0
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
Exemplo n.º 5
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
Exemplo n.º 6
0
def test_net_with_connectors_too_few():
	baseboard = read_dmidecode.get_baseboard(filedir + 'baseboard.txt')
	baseboard = read_dmidecode.get_connectors(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': 1,
		'mac': '00:c0:11:fe:fe:22',
		'sas-sata-ports-n': 2,
		'notes': 'Unknown connector: None / Other (AUDIO / AUDIO)\n'
			'BIOS reported 1 more ethernet port that was not found by the kernel'
	}
	output = read_dmidecode.get_net(filedir + 'net_too_few.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": "Microsoft Corporation",
		"model": "Surface Pro 4",
		"sn": "A01012111654643A",
		"notes": ""
	}
	output = read_dmidecode.get_connectors(os.path.join(filedir, 'connector.txt'), baseboard)

	assert output == expect
Exemplo n.º 8
0
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
Exemplo n.º 9
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
Exemplo n.º 10
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
Exemplo n.º 11
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
Exemplo n.º 12
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
Exemplo n.º 13
0
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
Exemplo n.º 14
0
def test_connector():
    baseboard = read_dmidecode.get_baseboard(filedir + 'baseboard.txt')

    expect = {
        'type': 'motherboard',
        "working": "yes",
        'brand': 'Apple Inc.',
        'model': 'Mac-2BD1B31983FE1663',
        'sn': 'C02433601ECG3MK13',
        'usb-ports-n': 3,
        'mini-jack-ports-n': 1,
        'hdmi-ports-n': 1,
        'mini-displayport-ports-n': 2,
        'power-connector': 'proprietary',
        'notes': ''
    }
    output = read_dmidecode.get_connectors(filedir + 'connector.txt',
                                           baseboard)

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

	expect = {
		"type": "motherboard",
		"working": "yes",
		"brand": "LENOVO",
		"model": "2718V8C",
		"sn": "VQ1FF05G1WA",
		"usb-ports-n": 3,
		"vga-ports-n": 1,
		"mini-jack-ports-n": 2,
		"ethernet-ports-n": 1,
		"firewire-ports-n": 1,
		"rj11-ports-n": 1,
		"notes": ""
	}
	output = read_dmidecode.get_connectors(os.path.join(filedir, 'connector.txt'), baseboard)

	assert output == expect
Exemplo n.º 16
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
Exemplo n.º 17
0
def test_connector():
	baseboard = read_dmidecode.get_baseboard(os.path.join(filedir, 'baseboard.txt'))

	expect = {
		"type": "motherboard",
		"working": "yes",
		"brand": "ASUSTeK Computer INC.",
		"model": "P5V-VM-ULTRA",
		"sn": "MB-1234567890",
		"ps2-ports-n": 2,
		"usb-ports-n": 8,
		"parallel-ports-n": 1,
		"serial-ports-n": 1,
		"mini-jack-ports-n": 3,
		"ethernet-ports-n": 1,
		"ide-ports-n": 2,
		"notes": ""
	}
	output = read_dmidecode.get_connectors(os.path.join(filedir, 'connector.txt'), baseboard)

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

	expect = {
		"type": "motherboard",
		"working": "yes",
		"brand": "Dell Inc.",
		"model": "0MY171",
		"sn": "CN125321L404Q",
		"serial-ports-n": 2,
		"ps2-ports-n": 2,
		"parallel-ports-n": 1,
		"firewire-ports-n": 2,
		"usb-ports-n": 8,
		"mini-jack-ports-n": 4,
		"ethernet-ports-n": 1,
		"notes": ""
	}
	output = read_dmidecode.get_connectors(os.path.join(filedir, 'connector.txt'), baseboard)

	assert output == expect
Exemplo n.º 19
0
def test_77_connector():
	baseboard = read_dmidecode.get_baseboard(os.path.join(filedir, 'baseboard.txt'))

	expect = {
		'brand': 'ASUSTeK Computer INC.',
		'model': 'P5SD2-VM',
		'sn': 'MT721CT11114269',
		'type': 'motherboard',
		"working": "yes",
		'usb-ports-n': 8,
		'ethernet-ports-n': 1,
		'mini-jack-ports-n': 3,
		'parallel-ports-n': 1,
		'ps2-ports-n': 2,
		'serial-ports-n': 1,
		'ide-ports-n': 1,
		'sata-ports-n': 2,
		'notes': 'Unknown connector: Other / None (AAFP / Not Specified)'
	}
	output = read_dmidecode.get_connectors(os.path.join(filedir, 'connector.txt'), baseboard)

	assert output == expect
Exemplo n.º 20
0
def test_connector():
	baseboard = read_dmidecode.get_baseboard(filedir + 'baseboard.txt')

	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-n": 2,
		'sas-sata-ports-n': 2,
		'notes': 'Unknown connector: None / Other (AUDIO / AUDIO)'
	}
	output = read_dmidecode.get_connectors(filedir + 'connector.txt', baseboard)

	assert output == expect
Exemplo n.º 21
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':
        'ASUSTeK Computer INC.',
        'ethernet-ports-n':
        1,
        'mini-jack-ports-n':
        1,
        'model':
        'P8H67-M LE',
        'notes':
        'Unknown connector: None / Other (AUDIO / AUDIO)\n'
        'Unknown connector: None / Other (DVI / DVI port)\n'
        'Unknown connector: None / Other (SPDIFO_HDMI / HDMI port)\n'
        'Unknown connector: Other / None (VGA / Not Specified)',
        'ps2-ports-n':
        1,
        'sata-ports-n':
        6,
        'sn':
        'A5D10110N3',
        'type':
        'motherboard',
        'usb-ports-n':
        8,
        'working':
        'yes',
    }
    output = read_dmidecode.get_connectors(
        os.path.join(filedir, 'connector.txt'), baseboard)

    assert output == expect
Exemplo n.º 22
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