"ValueError: invalid literal for int() with base 10: '2-1'" on VerboseParser().run() #19

Closed
opened 2020-12-17 21:51:03 +00:00 by rosaLux161 · 4 comments
rosaLux161 commented 2020-12-17 21:51:03 +00:00 (Migrated from gitlab.com)

When I run VerboseParser().run(), the following message is output:

Traceback (most recent call last):
  File "*.py", line 21, in <module>
    lspci_devices = VerboseParser().run()
  File "*/.local/lib/python3.8/site-packages/pylspci/parsers/base.py", line 49, in run
    return self.parse(lspci(**lspci_kwargs))
  File "*/.local/lib/python3.8/site-packages/pylspci/parsers/verbose.py", line 128, in parse
    result.append(self._parse_device(line))
  File "*/.local/lib/python3.8/site-packages/pylspci/parsers/verbose.py", line 99, in _parse_device
    devdict[field.field_name] = field.field_type(value)
ValueError: invalid literal for int() with base 10: '2-1'

Kernel: 5.4.80-2-MANJARO

Distro: Manjaro

lspci with 2-1

03:00.0 Non-Volatile memory controller: Samsung Electronics Co Ltd NVMe SSD Controller SM951/PM951 (rev 01) (prog-if 02 [NVM Express])
        Subsystem: Samsung Electronics Co Ltd Device a801
        Physical Slot: 2-1
        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx+
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 0, Cache Line Size: 32 bytes
        Interrupt: pin A routed to IRQ 29
        NUMA node: 0
        Region 0: Memory at fb110000 (64-bit, non-prefetchable) [size=16K]
        Region 2: I/O ports at d000 [size=256]
        Expansion ROM at fb100000 [disabled] [size=64K]
        Capabilities: <access denied>
        Kernel driver in use: nvme

Maybe you should change the field type from int to str for PhySlot

https://gitlab.com/Lucidiot/pylspci/-/blob/master/pylspci/parsers/verbose.py#L78

'PhySlot': FieldMapping(field_name='physical_slot', field_type=int),

to

'PhySlot': FieldMapping(field_name='physical_slot', field_type=str),
When I run VerboseParser().run(), the following message is output: ``` Traceback (most recent call last): File "*.py", line 21, in <module> lspci_devices = VerboseParser().run() File "*/.local/lib/python3.8/site-packages/pylspci/parsers/base.py", line 49, in run return self.parse(lspci(**lspci_kwargs)) File "*/.local/lib/python3.8/site-packages/pylspci/parsers/verbose.py", line 128, in parse result.append(self._parse_device(line)) File "*/.local/lib/python3.8/site-packages/pylspci/parsers/verbose.py", line 99, in _parse_device devdict[field.field_name] = field.field_type(value) ValueError: invalid literal for int() with base 10: '2-1' ``` Kernel: 5.4.80-2-MANJARO Distro: Manjaro # lspci with 2-1 ``` 03:00.0 Non-Volatile memory controller: Samsung Electronics Co Ltd NVMe SSD Controller SM951/PM951 (rev 01) (prog-if 02 [NVM Express]) Subsystem: Samsung Electronics Co Ltd Device a801 Physical Slot: 2-1 Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx+ Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx- Latency: 0, Cache Line Size: 32 bytes Interrupt: pin A routed to IRQ 29 NUMA node: 0 Region 0: Memory at fb110000 (64-bit, non-prefetchable) [size=16K] Region 2: I/O ports at d000 [size=256] Expansion ROM at fb100000 [disabled] [size=64K] Capabilities: <access denied> Kernel driver in use: nvme ``` Maybe you should change the field type from int to str for PhySlot https://gitlab.com/Lucidiot/pylspci/-/blob/master/pylspci/parsers/verbose.py#L78 ``` 'PhySlot': FieldMapping(field_name='physical_slot', field_type=int), ``` to ``` 'PhySlot': FieldMapping(field_name='physical_slot', field_type=str), ```
rosaLux161 commented 2020-12-17 21:53:33 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
rosaLux161 commented 2020-12-17 21:54:55 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
rosaLux161 commented 2020-12-17 22:15:20 +00:00 (Migrated from gitlab.com)

Just tested it locally and it works. It will add '-#' if duplicate slot numbers are found.

Just tested it locally and it works. It will add '-#' if duplicate slot numbers are found.
rosaLux161 commented 2020-12-17 22:20:04 +00:00 (Migrated from gitlab.com)

mentioned in merge request !13

mentioned in merge request !13
Sign in to join this conversation.
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: lucidiot/pylspci#19
No description provided.