{"id":27144388,"url":"https://github.com/arondight/python-dmiparser","last_synced_at":"2025-08-06T15:18:10.995Z","repository":{"id":45572691,"uuid":"228385790","full_name":"Arondight/python-dmiparser","owner":"Arondight","description":"This parse dmidecode output to JSON","archived":false,"fork":false,"pushed_at":"2024-02-28T14:31:35.000Z","size":91,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-11T17:00:12.009Z","etag":null,"topics":["dmidecode","parser","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/dmiparser/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Arondight.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-12-16T12:46:41.000Z","updated_at":"2022-08-15T03:38:29.000Z","dependencies_parsed_at":"2025-06-10T17:43:08.217Z","dependency_job_id":"626c7022-af55-4b02-9330-1692477210ae","html_url":"https://github.com/Arondight/python-dmiparser","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/Arondight/python-dmiparser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arondight%2Fpython-dmiparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arondight%2Fpython-dmiparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arondight%2Fpython-dmiparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arondight%2Fpython-dmiparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Arondight","download_url":"https://codeload.github.com/Arondight/python-dmiparser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arondight%2Fpython-dmiparser/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269102226,"owners_count":24360121,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-06T02:00:09.910Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dmidecode","parser","python"],"created_at":"2025-04-08T08:59:00.938Z","updated_at":"2025-08-06T15:18:10.975Z","avatar_url":"https://github.com/Arondight.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# python-dmiparser\n\n## About\n\nThis parse `dmidecode` output to JSON text.\n\n## Installation\n\n### PyPI\n\n```shell\npip3 install -U dmiparser\n```\n\n### RPM\n\n```shell\ngit clone https://github.com/Arondight/python-dmiparser.git\ncd ./python-dmiparser/\npython3 ./setup.py bdist --format=rpm\nsudo dnf install ./dist/dmiparser-*.noarch.rpm\n```\n\n\u003e Tip: Requires the `rpm-build` package in your Linux distribution.\n\n## Usage\n\n### Python 3 script\n\n#### DmiParser\n\nThis accepts a `str` (with the output of `dmidecode`) as argument and converts it to JSON text.\n\n```python\n#!/usr/bin/env python3\nimport json\nfrom dmiparser import DmiParser\nfrom functools import partial\n\n\ndef report(*args: str) -\u003e None:\n    \"\"\"report texts with format\n\n    @param args: text string\n    \"\"\"\n    br = lambda e: print(\"-\" * e)\n    brn = partial(br, 80)\n\n    brn()\n\n    for e in args:\n        print(e)\n        brn()\n\n\nif \"__main__\" == __name__:\n    text = (\n        \"# dmidecode 3.0\\n\"\n        \"Getting SMBIOS data from sysfs.\\n\"\n        \"SMBIOS 2.7 present.\\n\"\n        \"\\n\"\n        \"Handle 0x0003, DMI type 2, 17 bytes\\n\"\n        \"Base Board Information\\n\"\n        \"\\tManufacturer: Intel Corporation\\n\"\n        \"\\tProduct Name: S2600WT2R\\n\"\n        \"\\tVersion: H21573-372\\n\"\n        \"\\tSerial Number: BQWL81150522\\n\"\n        \"\\tAsset Tag: Base Board Asset Tag\\n\"\n        \"\\tFeatures:\\n\"\n        \"\\t\\tBoard is a hosting board\\n\"\n        \"\\t\\tBoard is replaceable\\n\"\n        \"\\tLocation In Chassis: Part Component\\n\"\n        \"\\tChassis Handle: 0x0000\\n\"\n        \"\\tType: Motherboard\\n\"\n        \"\\tContained Object Handles: 0\\n\"\n        \"\\n\"\n    )\n\n    # parser = DmiParser(text)\n    parser = DmiParser(text, sort_keys=True, indent=2)\n\n    parsedStr = str(parser)  # get str\n    parsedObj = json.loads(str(parser))  # get object\n\n    report(parsedStr, parsedObj)\n```\n\n#### DmiDecoder (the default wrapper)\n\nThis run `dmidecode` and converting the output of the command to JSON text.\n\n```python\nfrom dmiparser.dmidecoder import DmiDecoder\nfrom functools import partial\n\n\ndef report(*args: str) -\u003e None:\n    \"\"\"report texts with format\n\n    @param args: text string\n    \"\"\"\n    br = lambda e: print(\"-\" * e)\n    brn = partial(br, 80)\n\n    brn()\n\n    for e in args:\n        print(e)\n        brn()\n\n\ndef getCpuInfo(dmidecoder) -\u003e str:\n    \"\"\"Get CPU information, will return text like below.\n\n    CPU1:\n        Family: Xeon\n        Version: Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz\n        Voltage: 1.8 V\n        Speed: 2200 MHz/4000 MHz\n        Status: Populated, Enabled\n        Core: 10/10\n        Thread: 20\n    CPU2:\n        Family: Xeon\n        Version: Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz\n        Voltage: 1.8 V\n        Speed: 2200 MHz/4000 MHz\n        Status: Populated, Enabled\n        Core: 10/10\n        Thread: 20\n\n    @param: dmidecode: DmiDecode object\n    @return: text of CPU information\n    \"\"\"\n    text = \"\"\n\n    for id, name in dmidecoder.sections:\n        def getFirst(*args):\n            vals = dmidecoder.getProp(*args, id=id, name=name)\n            return vals[0] if len(vals) \u003e 0 else None\n\n        text += \"{}:\\n\".format(getFirst(\"Socket Designation\"))\n        text += \"\\tFamily: {}\\n\".format(getFirst(\"Family\"))\n        text += \"\\tVersion: {}\\n\".format(getFirst(\"Version\"))\n        text += \"\\tVoltage: {}\\n\".format(getFirst(\"Voltage\"))\n        text += \"\\tSpeed: {}/{}\\n\".format(getFirst(\"Current Speed\"), getFirst(\"Max Speed\"))\n        text += \"\\tStatus: {}\\n\".format(getFirst(\"Status\"))\n        text += \"\\tCore: {}/{}\\n\".format(getFirst(\"Core Enabled\"), getFirst(\"Core Count\"))\n        text += \"\\tThread: {}\\n\".format(getFirst(\"Thread Count\"))\n\n    return text\n\n\nif \"__main__\" == __name__:\n    # dmidecoder = DmiDecoder()\n    dmidecoder4 = DmiDecoder(\"-t 4\", sort_keys=True, indent=2)  # Type 4 is Processor\n\n    report(dmidecoder4.text, str(dmidecoder4.data), getCpuInfo(dmidecoder4))\n```\n\n\u003e Tip: Superuser permissions are required here to run `dmidecode`.\n\n### Executable command\n\n#### dmiparser\n\nThis read output of `dmidecode` from pipe and print it as JSON text.\n\n```shell\nsudo dmidecode | dmiparser\nsudo dmidecode -t 4 | dmiparser --format\n```\n\n```shell\nsudo dmidecode \u003e/tmp/dmidecode.txt\ndmiparser \u003c/tmp/dmidecode.txt\n```\n\n\u003e Tip: you can run `dmiparser` module as a script (use `python3 -m dmiparser` instead of `dmiparser` command).\n\n#### dmidecoder\n\nThis run `dmidecode` and print the output as JSON text.\n\n```shell\nsudo dmidecoder\nsudo dmidecoder --arguments \"-t 4\" --format\n```\n\n\u003e Tip: you can run `dmiparser.dmidecoder` module as a script (use `python3 -m dmiparser.dmidecoder` instead\n\u003e of `dmidecoder` command).\n\n## Development\n\n### Test\n\n```shell\ntox\n```\n\n### Format\n\n```shell\nblack -l 120 ./dmiparser/ ./tests/\n```\n\n## License\n\n[MIT LICENSE](https://github.com/Arondight/python-dmiparser/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farondight%2Fpython-dmiparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farondight%2Fpython-dmiparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farondight%2Fpython-dmiparser/lists"}