Beispiel #1
0
def test_chassis():
    # At least it's not assuming stuff it cannot know...
    expect = [{
        "type": "case",
    }]
    output = read_dmidecode.parse_case(read_file(filedir, "chassis.txt"))

    assert output == expect
Beispiel #2
0
def test_chassis():
    expect = [{
        "type": "case",
        "brand": "Chassis Manufacture",
        "sn": "Chassis Serial Number",
    }]
    output = read_dmidecode.parse_case(read_file(filedir, "chassis.txt"))

    assert output == expect
def test_chassis():
    expect = [{
        "type": "case",
        "brand": "Hewlett-Packard",
        "sn": "CZC6203MC5",
    }]
    output = read_dmidecode.parse_case(read_file(filedir, "chassis.txt"))

    assert output == expect
Beispiel #4
0
def test_chassis():
    expect = [{
        "type": "case",
        "brand": "Matsonic",
    }]

    output = read_dmidecode.parse_case(read_file(filedir, "chassis.txt"))

    assert output == expect
Beispiel #5
0
def test_chassis():
    expect = [{
        "type": "case",
        "brand": "LENOVO",
        "sn": "A2K3GED",
        "motherboard-form-factor": "proprietary-laptop",
    }]
    output = read_dmidecode.parse_case(read_file(filedir, "chassis.txt"))

    assert output == expect
Beispiel #6
0
def test_chassis():
    # This is also wrong, but for pre-assembled computers it should be right
    expect = [{
        "brand": "Gigabyte Technology Co., Ltd.",
        "sn": "To Be Filled By O.E.M",
        "type": "case",
    }]
    output = read_dmidecode.parse_case(read_file(filedir, "chassis.txt"))

    assert output == expect
Beispiel #7
0
def test_chassis():
    expect = [{
        "type": "case",
        "brand": "Microsoft Corporation",
        "sn": "CENSORED",
        "motherboard-form-factor": "proprietary-laptop",
    }]
    output = read_dmidecode.parse_case(read_file(filedir, "chassis.txt"))

    assert output == expect
Beispiel #8
0
def test_chassis():
    # This is also wrong, but for pre-assembled computers it should be right
    expect = [{
        "brand": "Chassis Manufacture",
        "sn": "Chassis Serial Number",
        "type": "case",
    }]
    output = read_dmidecode.parse_case(read_file(filedir, "chassis.txt"))

    assert output == expect
def test_chassis():
    expect = [
        {
            "type": "case",
            "brand": "Dell Inc.",
            "sn": "5ASDL3L",
        }
    ]
    output = read_dmidecode.parse_case(read_file(filedir, "chassis.txt"))

    assert output == expect
Beispiel #10
0
def call_parsers(
    generated_files_path: str,
    components: Set[ParserComponents],
    gpu_location: GpuLocation,
    interactive: bool = False,
) -> list:
    generated_files_path = generated_files_path.rstrip("/")

    def read_file(name: str) -> str:
        path = os.path.join(generated_files_path, name)
        try:
            with open(path, "r") as f:
                output = f.read()
            return output
        except FileNotFoundError:
            raise InputFileNotFoundError(path)

    result = []

    # TODO: if linux, else windows
    if sys.platform == "win32":
        pass
    else:
        if not components.isdisjoint(
            {ParserComponents.CASE, ParserComponents.MOTHERBOARD}):
            result += parse_motherboard(
                read_file("baseboard.txt"),
                read_file("connector.txt"),
                read_file("net.txt"),
                interactive,
            )
            if gpu_location == GpuLocation.MOTHERBOARD:
                _merge_gpu(
                    result,
                    "motherboard",
                    parse_lspci_and_glxinfo(False, read_file("lspci.txt"), ""),
                )
        if ParserComponents.CASE in components:
            result += parse_case(read_file("chassis.txt"),
                                 _find_component("motherboard", result))
        if ParserComponents.CPU in components:
            result += parse_lscpu(read_file("lscpu.txt"))
            if gpu_location == GpuLocation.CPU:
                _merge_gpu(
                    result,
                    "cpu",
                    parse_lspci_and_glxinfo(False, read_file("lspci.txt"), ""),
                )
        if ParserComponents.GPU in components and gpu_location == GpuLocation.DISCRETE:
            result += parse_lspci_and_glxinfo(True, read_file("lspci.txt"),
                                              read_file("glxinfo.txt"),
                                              interactive)
        if ParserComponents.RAM in components:
            result += parse_decode_dimms(read_file("dimms.txt"), interactive)
        if ParserComponents.HDD in components or ParserComponents.SSD in components:
            result += parse_smartctl(read_file("smartctl.txt"), interactive)
        if ParserComponents.PSU in components:
            result += parse_psu(_find_component("case", result))

    result = _do_cleanup(result, interactive)
    return result