parent
d745c95939
commit
a0a88e6285
@ -1,61 +1,61 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# Copyright (C) 2016 Richard Hughes <richard@hughsie.com>
|
# Copyright (C) 2021 Simone Caronni <negativo17@gmail.com>
|
||||||
# Licensed under the GNU General Public License Version or later
|
# Licensed under the GNU General Public License Version or later
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) != 3:
|
if len(sys.argv) != 2:
|
||||||
print("usage: %s README.txt \"header to match\"" % sys.argv[0])
|
print("usage: %s README.txt" % sys.argv[0])
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
# open file
|
|
||||||
f = open(sys.argv[1])
|
f = open(sys.argv[1])
|
||||||
in_section = False
|
in_section = False
|
||||||
in_table = False
|
in_table = False
|
||||||
pids = []
|
pids = []
|
||||||
for line in f.readlines():
|
sections = ["NVIDIA GEFORCE GPUS", "NVIDIA RTX/QUADRO GPUS", "NVIDIA NVS GPUS", "NVIDIA TESLA GPUS", "NVIDIA GRID GPUS"]
|
||||||
|
for section in sections:
|
||||||
# find the right data table
|
|
||||||
if line.find(sys.argv[2]) != -1:
|
for line in f.readlines():
|
||||||
in_section = True
|
|
||||||
continue
|
# Find the right data tables
|
||||||
if not in_section:
|
if line.find(section) != -1:
|
||||||
continue
|
in_section = True
|
||||||
|
continue
|
||||||
# remove Windows and Linux line endings
|
if not in_section:
|
||||||
line = line.replace('\r', '')
|
continue
|
||||||
line = line.replace('\n', '')
|
|
||||||
|
# Remove Windows and Linux line endings
|
||||||
# end of section
|
line = line.replace('\r', '')
|
||||||
if len(line) > 0 and not line.startswith(' '):
|
line = line.replace('\n', '')
|
||||||
in_section = False
|
|
||||||
in_table = False
|
# End of section
|
||||||
continue
|
if len(line) > 0 and not line.startswith(' '):
|
||||||
|
in_section = False
|
||||||
# empty line
|
in_table = False
|
||||||
if len(line) == 0:
|
continue
|
||||||
continue
|
|
||||||
|
if len(line) == 0:
|
||||||
# skip the header
|
continue
|
||||||
if line.startswith(' ---'):
|
|
||||||
in_table = True
|
# Skip the header
|
||||||
continue
|
if line.startswith(' ---'):
|
||||||
if not in_table:
|
in_table = True
|
||||||
continue
|
continue
|
||||||
|
if not in_table:
|
||||||
# get name
|
continue
|
||||||
pid = int(line[42:46], 16)
|
|
||||||
if not pid in pids:
|
# PCI ID
|
||||||
pids.append(pid)
|
pid = int(line[50:54], 16)
|
||||||
|
if not pid in pids:
|
||||||
# output
|
pids.append(pid)
|
||||||
|
|
||||||
for pid in pids:
|
for pid in pids:
|
||||||
vid = 0x10de
|
vid = 0x10de
|
||||||
print("pci:v%08Xd%08Xsv*sd*bc*sc*i*" % (vid, pid))
|
print("pci:v%08Xd%08Xsv*sd*bc*sc*i*" % (vid, pid))
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
Loading…
Reference in new issue