parseQueues in base/queues.py parses 'lpstat -v' output incorrectly, leading to traceback

Bug #2027972 reported by zdohnal
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
HPLIP
New
Undecided
Unassigned
hplip (Fedora)
Fix Released
Undecided

Bug Description

If you call 'hp-diagnose_queues', it ends with traceback:

$ hp-diagnose_queues

HP Linux Imaging and Printing System (ver. 3.23.5)
AutoConfig Utility to check queues configuration ver. 1.1

Copyright (c) 2001-18 HP Development Company, LP
This software comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to distribute it
under certain conditions. See COPYING file for more details.

QSocketNotifier: Can only be used with threads started with QThread
qt.qpa.qgnomeplatform.theme: The desktop style for QtQuick Controls 2 applications is not available on the system (qqc2-desktop-style). The application may look broken.
Traceback (most recent call last):
  File "/usr/bin/hp-diagnose_queues", line 120, in <module>
    queues.main_function(passwordObj, mode,ui_toolkit, quiet_mode )
  File "/usr/share/hplip/base/queues.py", line 385, in main_function
    mapofDevices,status = parseQueues(mode)
                          ^^^^^^^^^^^^^^^^^
  File "/usr/share/hplip/base/queues.py", line 115, in parseQueues
    if device_uri.startswith("cups-pdf:/"):
       ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'startswith'

It happens because the LPSTAT_PATTERN fails to parse the 'lpstat -v' output correctly. The output looks f.e. like this:

$ lpstat -v
device for test: socket://192.168.5.4:9100

and the LPSTAT_PATTERN is defined as this regexp:

LPSTAT_PATTERN = re.compile(r"""(\S*)(\s)?: (.*)""", re.IGNORECASE)

, so the requested URI is in 3rd matched group, not in the second as parseQueues() tries.

I've written a patch which fixes the issue, it is attached.

This issue was introduced in 3.22.10, where lpstat pattern changed.

Revision history for this message
In , Ahmad.javid (ahmad.javid-redhat-bugs) wrote :

Description of problem:
Not Load xsane app
and error for the scan paper

Version-Release number of selected component:
hplip-3.22.10-4.fc38

Additional info:
reporter: libreport-2.17.9
kernel: 6.2.11-300.fc38.x86_64
cmdline: /usr/bin/python3 /usr/bin/hp-diagnose_queues --gui
cgroup: 0::/user.slice/user-1000.slice/user@1000.service/app.slice/app-gnome-hplip-58280.scope
uid: 1000
reason: queues.py:115:parseQueues:AttributeError: 'NoneType' object has no attribute 'startswith'
executable: /usr/bin/hp-diagnose_queues
type: Python3
package: hplip-3.22.10-4.fc38
runlevel: N 5
exception_type: AttributeError
crash_function: parseQueues
interpreter: python3-3.11.2-1.fc38.x86_64

Truncated backtrace:
queues.py:115:parseQueues:AttributeError: 'NoneType' object has no attribute 'startswith'

Traceback (most recent call last):
  File "/usr/bin/hp-diagnose_queues", line 120, in <module>
    queues.main_function(passwordObj, mode,ui_toolkit, quiet_mode )
  File "/usr/share/hplip/base/queues.py", line 385, in main_function
    mapofDevices,status = parseQueues(mode)
                          ^^^^^^^^^^^^^^^^^
  File "/usr/share/hplip/base/queues.py", line 115, in parseQueues
    if device_uri.startswith("cups-pdf:/"):
       ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'startswith'

Local variables in innermost frame:
mode: 1
is_hpcups_installed: True
is_hpijs_installed: False
st: 0
output: 'device for HP_LaserJet_Pro_MFP_M127fn: hp:/usb/HP_LaserJet_Pro_MFP_M127fn?serial=CNB9G9B4P8\r\ndevice for HP_LaserJet_Pro_MFP_M127fn-JAVID: hp:/usb/HP_LaserJet_Pro_MFP_M127fn?serial=CNB9G9B4P8\r\ndevice for HP_LaserJet_Pro_MFP_M127fn_fax: hpfax:/usb/HP_LaserJet_Pro_MFP_M127fn?serial=CNB9G9B4P8\r\ndevice for HP_LaserJet_Pro_MFP_M127fn_fax-JAVID: hpfax:/usb/HP_LaserJet_Pro_MFP_M127fn?serial=CNB9G9B4P8\r\n'
status: True
cups_printers: [('HP_LaserJet_Pro_MFP_M127fn', None), ('HP_LaserJet_Pro_MFP_M127fn-JAVID', None), ('HP_LaserJet_Pro_MFP_M127fn_fax', None), ('HP_LaserJet_Pro_MFP_M127fn_fax-JAVID', None)]
p: ('HP_LaserJet_Pro_MFP_M127fn', None)
match: <re.Match object; span=(11, 104), match='HP_LaserJet_Pro_MFP_M127fn_fax-JAVID: hpfax:/usb/>
printer_name: 'HP_LaserJet_Pro_MFP_M127fn'
device_uri: None

Revision history for this message
In , Ahmad.javid (ahmad.javid-redhat-bugs) wrote :

Created attachment 1961022
File: os_info

Revision history for this message
In , Ahmad.javid (ahmad.javid-redhat-bugs) wrote :

Created attachment 1961023
File: environ

Revision history for this message
In , Ahmad.javid (ahmad.javid-redhat-bugs) wrote :

Created attachment 1961024
File: mountinfo

Revision history for this message
In , Ahmad.javid (ahmad.javid-redhat-bugs) wrote :

Created attachment 1961025
File: open_fds

Revision history for this message
In , Ahmad.javid (ahmad.javid-redhat-bugs) wrote :

Created attachment 1961026
File: namespaces

Revision history for this message
In , Ahmad.javid (ahmad.javid-redhat-bugs) wrote :

Created attachment 1961027
File: backtrace

Revision history for this message
In , Ahmad.javid (ahmad.javid-redhat-bugs) wrote :

Created attachment 1961028
File: cpuinfo

Revision history for this message
In , zdohnal (zdohnal-redhat-bugs) wrote :

*** Bug 2176910 has been marked as a duplicate of this bug. ***

Revision history for this message
In , zdohnal (zdohnal-redhat-bugs) wrote :

Created attachment 1975792
Proposed patch

Revision history for this message
zdohnal (zdohnal) wrote :
Revision history for this message
In , zdohnal (zdohnal-redhat-bugs) wrote :

Fixed in rawhide for now, I will propagate it to the stable releases https://bodhi.fedoraproject.org/updates/FEDORA-2023-077b459bc2 .

Revision history for this message
In , updates (updates-redhat-bugs) wrote :

FEDORA-2023-5de7dea2a5 has been submitted as an update to Fedora 38. https://bodhi.fedoraproject.org/updates/FEDORA-2023-5de7dea2a5

Revision history for this message
In , updates (updates-redhat-bugs) wrote :

FEDORA-2023-dec484f9d2 has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2023-dec484f9d2

Revision history for this message
In , updates (updates-redhat-bugs) wrote :

FEDORA-2023-5de7dea2a5 has been pushed to the Fedora 38 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-5de7dea2a5`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-5de7dea2a5

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Revision history for this message
In , updates (updates-redhat-bugs) wrote :

FEDORA-2023-dec484f9d2 has been pushed to the Fedora 37 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-dec484f9d2`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-dec484f9d2

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Revision history for this message
In , updates (updates-redhat-bugs) wrote :

FEDORA-2023-5f9104efcd has been pushed to the Fedora 38 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-5f9104efcd`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-5f9104efcd

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Revision history for this message
In , updates (updates-redhat-bugs) wrote :

FEDORA-2023-8144e3fe2f has been pushed to the Fedora 37 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-8144e3fe2f`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-8144e3fe2f

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Revision history for this message
In , updates (updates-redhat-bugs) wrote :

FEDORA-2023-5f9104efcd has been pushed to the Fedora 38 stable repository.
If problem still persists, please make note of it in this bug report.

Changed in hplip (Fedora):
importance: Unknown → Undecided
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.