def test_lscpu(): expect = [ { "type": "cpu", "working": "yes", "isa": "x86-64", "model": "Xeon 5160", "brand": "Intel", "core-n": 2, "thread-n": 2, "frequency-hertz": 3000000000, }, { "type": "cpu", "working": "yes", "isa": "x86-64", "model": "Xeon 5160", "brand": "Intel", "core-n": 2, "thread-n": 2, "frequency-hertz": 3000000000, }, ] output = read_lscpu.parse_lscpu(read_file(filedir, "lscpu.txt")) assert isinstance(expect, list) assert len(expect) == 2 assert output == expect
def test_lscpu(): expect = [{ "type": "cpu", "working": "yes", "isa": "x86-64", "model": "Core i5-3210M", "brand": "Intel", "core-n": 2, "thread-n": 4, "frequency-hertz": 2500000000, }] output = read_lscpu.parse_lscpu(read_file(filedir, "lscpu.txt")) assert output == expect
def test_lscpu(): expect = [{ "type": "cpu", "working": "yes", "isa": "x86-32", "model": "Celeron 2.80GHz", "brand": "Intel", "core-n": 1, "thread-n": 1, "frequency-hertz": 2800000000, }] output = read_lscpu.parse_lscpu(read_file(filedir, "lscpu.txt")) assert output == expect
def test_lscpu(): expect = [{ "type": "cpu", "working": "yes", "isa": "x86-64", "model": "FX-8370E", "brand": "AMD", "core-n": 4, "thread-n": 8, "frequency-hertz": 3300000000, }] output = read_lscpu.parse_lscpu(read_file(filedir, "lscpu.txt")) assert output == expect
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