- vendorid= self.remove_quotes(parts[3])
- vendorid= long(vendorid,16)
- except IndexError:
- print( "Skipping invalid vendorid:", string.strip(line) )
- continue
- except ValueError, e:
- print( "Skipping invalid vendorid:", string.strip(line) )
- continue
-
- # parse in deviceid
- try:
- deviceid= self.remove_quotes(parts[4])
- deviceid= long(deviceid,16)
- except IndexError:
- print( "Skipping invalid deviceid:", string.strip(line) )
- continue
- except ValueError, e:
- print( "Skipping invalid deviceid:", string.strip(line) )
- continue
-
- # Now get the subvendor & subdevice portion by searching
- # parts[5:] of the lspci output. Note that we have to skip
- # the portions of the lspci output string that indicate
- # revision info.
-
- # parse in subvendorid
- subvendorindex = -1
- for i in range(5,len(parts)):
- p = self.remove_quotes(parts[i])
- if len(p)>0 and p[0] != '-':
- subvendorindex = i
- break
-
- if subvendorindex != -1:
- try:
- subvendorid= self.remove_quotes(parts[subvendorindex])
- subvendorid= long(subvendorid,16)
- except IndexError:
- print( "Skipping invalid line:", string.strip(line) )
- continue
- except ValueError, e:
- print( "Skipping invalid line:", string.strip(line) )
- continue
-
- # parse in subdeviceid
- subdeviceindex = -1
- for i in range(subvendorindex+1,len(parts)):
- p = self.remove_quotes(parts[i])
- if p[0] != '-':
- subdeviceindex = i
- break
- if subdeviceindex != -1:
- error_msg = "Skipping invalid subdeviceid:"
- try:
- subdeviceid= self.remove_quotes(parts[subdeviceindex])
- subdeviceid= long(subdeviceid,16)
- except IndexError:
- print( error_msg, string.strip(line) )
- continue
- except ValueError, e:
- print( error_msg, string.strip(line) )
- continue