Esempio n. 1
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. 2
0
def test_lspci():
	expect = {
		"type": "graphics-card",
		"working": "yes",
		"brand": "ASUSTeK Computer Inc.",
		"model": "Chrome 9 HC",
		"internal-name": "CN896/VN896/P4M900",
		"capacity-byte": None,
		"brand-manufacturer": "VIA"
	}
	output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(False, os.path.join(filedir, 'lspci.txt'), os.path.join(filedir, 'glxinfo.txt'))

	assert output == expect
Esempio n. 3
0
def test_lspci():
	expect = {
		"type": "graphics-card",
		"working": "yes",
		"brand": "ASUSTeK Computer Inc.",
		"model": "GeForce GT 610",
		"internal-name": "GF119",
		"capacity-byte": None,  # Still no glxinfo :(
		"brand-manufacturer": "Nvidia"
	}
	output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(False, os.path.join(filedir, 'lspci.txt'), os.path.join(filedir, 'glxinfo.txt'))

	assert output == expect
Esempio n. 4
0
def test_lspci_dedicated2():
	expect = {
		"type": "graphics-card",
		"working": "yes",
		"brand": "ASUSTeK Computer Inc.",
		'internal-name': 'G96',
		"model": "GeForce 9400 GT",
		"capacity-byte": 1073741824,
		"brand-manufacturer": "Nvidia"
	}
	output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(True, os.path.join(filedir, 'dedicated/lspci-9400GT.txt'), os.path.join(filedir, 'dedicated/glxinfo-9400GT.txt'))

	assert output == expect
Esempio n. 5
0
def test_lspci_dedicated3():
	expect = {
		"type": "graphics-card",
		"working": "yes",
		"brand": "ASUSTeK Computer Inc.",
		'internal-name': 'GM204',
		"model": "GeForce GTX 970",
		"capacity-byte": 4294967296,
		"brand-manufacturer": "Nvidia"
	}
	output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(True, os.path.join(filedir, 'dedicated/lspci-gtx-970.txt'), os.path.join(filedir, 'dedicated/glxinfo-gtx-970.txt'))

	assert output == expect
Esempio n. 6
0
def test_77_lspci():
	expect = {
		'type': 'graphics-card',
		"working": "yes",
		'brand-manufacturer': 'SiS',
		'brand': 'ASUSTeK Computer Inc.',
		'internal-name': '',
		'model': '771/671',
		'capacity-byte': None,
		'human_readable_capacity': ''}
	output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(False, os.path.join(filedir, 'lspci.txt'), os.path.join(filedir, 'glxinfo.txt'))

	assert output == expect
def test_lspci():
	expect = {
		"type": "graphics-card",
		"working": "yes",
		"brand": "Microsoft Corporation",
		"model": "HD Graphics 515",
		'internal-name': '',
		"capacity-byte": None,
		"brand-manufacturer": "Intel"
	}
	output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(False, os.path.join(filedir, 'lspci.txt'), os.path.join(filedir, 'glxinfo.txt'))

	assert output == expect
Esempio n. 8
0
def test_lspci_integrated():
	expect = {
		'type': 'graphics-card',
		"working": "yes",
		'brand': 'Hewlett-Packard Company',
		'model': '82945G/GZ',
		'internal-name': '',
		'capacity-byte': None,
		'human_readable_capacity': '',
		'brand-manufacturer': 'Intel'
	}
	output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(False, os.path.join(filedir, '82945G/lspci.txt'), os.path.join(filedir, '82945G/glxinfo.txt'))

	assert output == expect
Esempio n. 9
0
def test_lspci_dedicated():
	expect = {
		'type': 'graphics-card',
		"working": "yes",
		'brand': 'PC Partner Limited / Sapphire Technology',
		'internal-name': 'G98',
		'model': 'GeForce G 100',
		'capacity-byte': 536870912,  # This has 512 MB ov VRAM, but glxinfo reports 496?
		'human_readable_capacity': '496 MB',
		'brand-manufacturer': 'Nvidia'
	}
	output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(True, os.path.join(filedir, 'NVIDIA-G100/lspci.txt'), os.path.join(filedir, 'NVIDIA-G100/glxinfo.txt'))

	assert output == expect
Esempio n. 10
0
def test_lspci():
	expect = {
		"type": "graphics-card",
		"working": "yes",
		"brand": "Lenovo",
		"model": "Mobile 4 Series Chipset",
		"internal-name": "",
		"capacity-byte": None,
		"human_readable_capacity": "",
		"brand-manufacturer": "Intel"
	}
	output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(False, os.path.join(filedir, 'lspci.txt'), os.path.join(filedir, 'glxinfo.txt'))

	assert output == expect
Esempio n. 11
0
def test_lspci():
	expect = {
		"type": "graphics-card",
		"working": "yes",
		"brand": "ZOTAC International (MCO) Ltd.",
		"model": "GeForce GTX 1060 6GB",
		'internal-name': 'GP106',
		"capacity-byte": 6442450944,
		"human_readable_capacity": "6144 MB",
		"brand-manufacturer": "Nvidia"
	}
	output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(True, os.path.join(filedir, 'lspci.txt'), os.path.join(filedir, 'glxinfo.txt'))

	assert output == expect
Esempio n. 12
0
def test_lspci():
	expect = {
		"type": "graphics-card",
		"working": "yes",
		"brand": "ASUSTeK Computer Inc.",
		"model": "GeForce 9600 GT",
		"internal-name": "G94",
		"capacity-byte": None,
		"brand-manufacturer": "Nvidia"
	}
	# False to ignore missing glxinfo
	output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(False, os.path.join(filedir, 'lspci.txt'), os.path.join(filedir, 'glxinfo.txt'))

	assert output == expect
Esempio n. 13
0
def test_lspci():
    expect = {
        'type': 'graphics-card',
        "working": "yes",
        'brand-manufacturer': 'AMD/ATI',
        'internal-name': '',
        'brand': 'PC Partner Limited / Sapphire Technology Tahiti PRO',
        'model': 'Radeon HD 7950/8950 OEM / R9 280',
        'capacity-byte': 3221225472,
    }
    output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(
        True, os.path.join(filedir, 'lspci.txt'),
        os.path.join(filedir, 'glxinfo.txt'))

    assert output == expect
Esempio n. 14
0
def test_lspci():
    expect = {
        'brand': 'ASUSTeK Computer Inc.',
        'brand-manufacturer': 'Nvidia',
        'capacity-byte': 1073741824,
        'internal-name': 'GF106',
        'model': 'GeForce GTS 450',
        'type': 'graphics-card',
        'working': 'yes',
    }
    output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(
        True, os.path.join(filedir, 'lspci.txt'),
        os.path.join(filedir, 'glxinfo.txt'))

    assert output == expect
Esempio n. 15
0
def test_lspci():
    expect = {
        "type": "graphics-card",
        "working": "yes",
        "brand": "SiS",
        'internal-name': '',
        "model": "65x/M650/740",
        "capacity-byte": None,
    }

    output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(
        False, os.path.join(filedir, 'lspci.txt'),
        os.path.join(filedir, 'glxinfo.txt'))

    assert output == expect
Esempio n. 16
0
def test_lspci():
    expect = {
        "type": "graphics-card",
        "working": "yes",
        "brand": "ASUSTeK Computer Inc.",
        "model": "S3 UniChrome Pro",
        "internal-name": "P4M890",
        "capacity-byte": None,
        "human_readable_capacity": "",
        "brand-manufacturer": "VIA"
    }
    output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(
        False, filedir + 'lspci.txt', filedir + 'glxinfo.txt')

    assert output == expect
Esempio n. 17
0
def test_lspci():
    expect = {
        'type': 'graphics-card',
        "working": "yes",
        'brand-manufacturer': 'Nvidia',
        'brand': 'Apple Inc.',
        'internal-name': 'GK107M',
        'model': 'GeForce GT 750M Mac Edition',
        'capacity-byte': 2147483648,
        'human_readable_capacity': '2048 MB'
    }
    output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(
        True, filedir + 'lspci.txt', filedir + 'glxinfo.txt')

    assert output == expect
Esempio n. 18
0
def test_lspci_dedicated1():
	filesubdir = 'dedicated/NVIDIA6200/'
	expect = {
		"type": "graphics-card",
		"working": "yes",
		"brand": "ASUSTeK Computer Inc.",
		'internal-name': 'NV44',
		"model": "GeForce 6200 SE TurboCache",
		"capacity-byte": 67108864,  # 64 MB
		"brand-manufacturer": "Nvidia"
	}

	output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(True, os.path.join(os.path.join(filedir, filesubdir), 'lspci.txt'), os.path.join(os.path.join(filedir, filesubdir), 'glxinfo.txt'))

	assert output == expect
Esempio n. 19
0
def test_lspci():
    expect = {
        'type': 'graphics-card',
        "working": "yes",
        'brand-manufacturer': 'AMD/ATI',
        'brand': 'Apple Inc. Radeon Pro 560X',
        'internal-name': '',
        'model': 'Radeon RX 460/560D / Pro 450/455/460/555/555X/560/560X',
        'capacity-byte': 4294967296,
    }
    output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(
        True, os.path.join(filedir, 'lspci.txt'),
        os.path.join(filedir, 'glxinfo.txt'))

    assert output == expect
Esempio n. 20
0
def test_lspci():
    expect = {
        "type": "graphics-card",
        "working": "yes",
        "brand": "SiS",
        'internal-name': '',
        "model": "65x/M650/740",
        "capacity-byte": None,
        "human_readable_capacity": ""
    }

    output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(
        False, filedir + 'lspci.txt', filedir + 'glxinfo.txt')

    assert output == expect
Esempio n. 21
0
def test_lspci():
    expect = {
        'type': 'graphics-card',
        "working": "yes",
        'brand-manufacturer': 'Nvidia',
        'brand': 'Apple Inc.',
        'internal-name': 'GK107M',
        'model': 'GeForce GT 750M Mac Edition',
        'capacity-byte': 2147483648,
    }
    output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(
        True, os.path.join(filedir, 'lspci.txt'),
        os.path.join(filedir, 'glxinfo.txt'))

    assert output == expect
Esempio n. 22
0
def test_lspci():
	expect = {
		"type": "graphics-card",
		"working": "yes",
		"brand": "ASUSTeK Computer Inc.",
		"model": "GeForce 9400 GT",
		"internal-name": "G96",
		"capacity-byte": None,  # Missing glxinfo...
		"human_readable_capacity": "",
		"brand-manufacturer": "Nvidia"
	}
	# False to ignore missing glxinfo
	output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(False, filedir + 'lspci.txt', filedir + 'glxinfo.txt')

	assert output == expect
Esempio n. 23
0
def test_lspci():
    expect = {
        'type': 'graphics-card',
        "working": "yes",
        'brand-manufacturer': 'Intel',
        'brand': 'ASUSTeK Computer Inc.',
        'internal-name': '',
        'model': 'HD Graphics 515',
        'capacity-byte': None,
        'human_readable_capacity': ''
    }
    output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(
        False, filedir + 'lspci.txt', filedir + 'glxinfo.txt')

    assert output == expect
Esempio n. 24
0
def test_lspci_integrated_mobo_3():
	filesubdir = 'integrated/on-mobo/'
	file = 'ES1000'

	expect = {
		"type": "graphics-card",
		"working": "yes",
		"brand": "Intel Corporation",
		"model": "ES1000",
		"internal-name": "",
		"capacity-byte": None,
		"brand-manufacturer": "AMD/ATI"
	}
	output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(False, os.path.join(os.path.join(filedir, filesubdir), f'lspci-{file}.txt'), os.path.join(os.path.join(filedir, filesubdir), f'/glxinfo-{file}.txt'))

	assert output == expect
Esempio n. 25
0
def test_lspci_integrated_mobo_1():
	filesubdir = 'integrated/on-mobo/'
	file = '8300GT'

	expect = {
		"type": "graphics-card",
		"working": "yes",
		"brand": "ASUSTeK Computer Inc.",
		"model": "GeForce 8300",
		"internal-name": "C77",
		"capacity-byte": None,
		"brand-manufacturer": "Nvidia"
	}
	output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(False, os.path.join(os.path.join(filedir, filesubdir), f'lspci-{file}.txt'), os.path.join(os.path.join(filedir, filesubdir), f'/glxinfo-{file}.txt'))

	assert output == expect
Esempio n. 26
0
def test_lspci_integrated_cpu_3():
	filesubdir = 'integrated/on-cpu/Xeon/'

	expect = {
		"type": "graphics-card",
		"working": "yes",
		"brand": "ASRock Incorporation",
		"model": "Xeon E3-1200 v3/4th Gen Core Processor",
		"internal-name": "",
		"capacity-byte": None,
		"brand-manufacturer": "Intel"
	}
	output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(False, os.path.join(os.path.join(filedir, filesubdir), 'lspci.txt'),
	                                      os.path.join(os.path.join(filedir, filesubdir), 'glxinfo.txt'))

	assert output == expect
Esempio n. 27
0
def test_lspci_integrated_cpu_1():
	filesubdir = 'integrated/on-cpu/Acer Swift 3/'

	expect = {
		"type": "graphics-card",
		"working": "yes",
		"brand": "Acer Incorporated",
		"model": "Skylake GT2 [HD Graphics 520]",
		"internal-name": "",
		"capacity-byte": None,
		"brand-manufacturer": "Intel"
	}
	output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(False, os.path.join(os.path.join(filedir, filesubdir), 'lspci.txt'),
	                                      os.path.join(os.path.join(filedir, filesubdir), 'glxinfo.txt'))

	assert output == expect
Esempio n. 28
0
def test_lspci():
    # VGA core graphics processor core VGA processor graphics core VGA processor is the core of this laptop
    expect = {
        "type": "graphics-card",
        "working": "yes",
        "brand": "Lenovo 3rd Gen Core processor Graphics Controller",
        "model": "VGA controller",
        "internal-name": "",
        "capacity-byte": None,
        "brand-manufacturer": "Intel"
    }
    output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(
        False, os.path.join(filedir, 'lspci.txt'),
        os.path.join(filedir, 'glxinfo.txt'))

    assert output == expect
Esempio n. 29
0
def test_lspci_integrated_cpu_2():
	filesubdir = 'integrated/on-cpu/HP EliteBook 2540p (i5 M540)/'

	# Yeeeeah, nice and detailed - not.
	expect = {
		"type": "graphics-card",
		"working": "yes",
		"brand": "Hewlett-Packard Company Core Processor",
		"model": "",
		"internal-name": "",
		"capacity-byte": None,
		"brand-manufacturer": "Intel"
	}
	output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(False, os.path.join(os.path.join(filedir, filesubdir), 'lspci.txt'),
	                                      os.path.join(os.path.join(filedir, filesubdir), 'glxinfo.txt'))

	assert output == expect
Esempio n. 30
0
def test_lspci_integrated_mobo_2():
	filesubdir = 'integrated/on-mobo/'
	file = '82865G'

	expect = {
		"type": "graphics-card",
		"working": "yes",
		"brand": "Lite-On Technology Corporation",
		"model": "82865G",
		"internal-name": "",
		"capacity-byte": None,
		"human_readable_capacity": "",
		"brand-manufacturer": "Intel"
	}
	output = read_lspci_and_glxinfo.read_lspci_and_glxinfo(False, os.path.join(os.path.join(filedir, filesubdir), f'lspci-{file}.txt'), os.path.join(os.path.join(filedir, filesubdir), f'/glxinfo-{file}.txt'))

	assert output == expect