Comment 1 for bug 1891183

Revision history for this message
Jam Hernandez Quiceno (jam369) wrote :

Here is the output without the fix:
Traceback (most recent call last):
  File "/usr/bin/nvidia-detector", line 8, in <module>
    a = NvidiaDetection(printonly=True, verbose=False)
  File "/usr/lib/python3/dist-packages/NvidiaDetector/nvidiadetector.py", line 73, in __init__
    self.getData()
  File "/usr/lib/python3/dist-packages/NvidiaDetector/nvidiadetector.py", line 163, in getData
    driver_version = self.__get_value_from_name(stripped_package_name)
  File "/usr/lib/python3/dist-packages/NvidiaDetector/nvidiadetector.py", line 92, in __get_value_from_name
    v = int(name)
ValueError: invalid literal for int() with base 10: 'server'

Here are is my solution:

In function
    # line 88
    def __get_value_from_name(self, name):
        '''Get the integer associated to the name of a driver'''
        v = self.__driver_aliases.get(name)
        if v is None:
            if name.isdigit(): # I made sure is an int.
                v = int(name)
        return v

    # in line 164 I replaced with :
            if not (driver_version := self.__get_value_from_name(stripped_package_name)):
                continue