Error with hplip/base/utils.py translate call in Debian hplip 3.18.12+dfsg0-2 causes setup to fail

Bug #1826988 reported by Scott Kitterman
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
HPLIP
In Progress
Undecided
Unassigned

Bug Description

Fax setup fails (causing the entire setup to fail) with this traceback:

Traceback (most recent call last):
  File "/usr/share/hplip/ui5/setupdialog.py", line 1304, in NextButton_clicked
    self.showAddPrinterPage()
  File "/usr/share/hplip/ui5/setupdialog.py", line 728, in showAddPrinterPage
    self.readwriteFaxInformation()
  File "/usr/share/hplip/ui5/setupdialog.py", line 1127, in readwriteFaxInformation
    self.fax_number = to_unicode(d.getPhoneNum())
  File "/usr/share/hplip/fax/pmlfax.py", line 146, in getPhoneNum
    data = utils.printable(self.getPML(pml.OID_FAX_LOCAL_PHONE_NUM)[1])
  File "/usr/share/hplip/base/utils.py", line 959, in printable
    return s.translate(identity, unprintable)
TypeError: translate() takes exactly one argument (2 given)

Please see the attached log to show debug runs before and after my change:

--- utils.py 2019-04-29 23:49:03.202551465 -0400
+++ utils.py.new 2019-04-29 23:49:34.934764539 -0400
@@ -956,7 +956,7 @@

 def printable(s):
     if s:
- return s.translate(identity, unprintable)
+ return s.translate(identity)
     else:
         return ""

Since I'm working in English, I don't know if that affects the translation functionality, but it was enough for me to be able to finish my printer setup.

Tags: patch
Revision history for this message
Scott Kitterman (kitterman) wrote :
Revision history for this message
Santhosh Manchikanti (santhosh2357651) wrote :

Thanks Scott,

Will verify the changes.

Regards,
Santhosh

Changed in hplip:
status: New → In Progress
Revision history for this message
Leonidas (jpegxguy) wrote :

This has been an issue for a while now. A lot of the hplip functionality depends on that line of code. The translate function you're using doesn't work in python 3.

$ hp-faxsetup

HP Linux Imaging and Printing System (ver. 3.19.8)
Fax Device Setup Utility ver. 0.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.

qt5ct: using qt5ct plugin
Traceback (most recent call last):
  File "/usr/share/hplip/ui5/faxsetupdialog.py", line 139, in FaxComboBox_currentChanged
    self.updateHeaderTab()
  File "/usr/share/hplip/ui5/faxsetupdialog.py", line 254, in updateHeaderTab
    name_company = to_unicode(self.dev.getStationName())
  File "/usr/share/hplip/fax/pmlfax.py", line 158, in getStationName
    data = utils.printable(self.getPML(pml.OID_FAX_STATION_NAME)[1])
  File "/usr/share/hplip/base/utils.py", line 958, in printable
    return s.translate(identity, unprintable)
TypeError: translate() takes exactly one argument (2 given)
Ακυρώθηκε (core dumped)

Let's try with python2. It will fail to launch because the module named in the error is only shipped for python3 from hplip.

$ python2 /usr/bin/hp-faxsetup
Traceback (most recent call last):
  File "/usr/bin/hp-faxsetup", line 38, in <module>
    from base import device, utils, maint, tui, module
  File "/usr/share/hplip/base/device.py", line 42, in <module>
    from . import status
  File "/usr/share/hplip/base/status.py", line 33, in <module>
    import cupsext
ImportError: No module named cupsext

It seems like an easy fix to use some combination of the py3 maketrans + translate functions or something.

Please fix this. It's a major issue as it stops a lot of the functionality, no GUI for printer install, no Fax setup etc.

Revision history for this message
Leonidas (jpegxguy) wrote :

My bad, seems like a patch has been provided. Even better, hoping to see this fixed soon,

Revision history for this message
Marek Nečada (u-marek) wrote :

Just wanted to bump this. This bug makes the package almost unusable, especially for less experimented users who can't patch utils.py manually, which is pretty grave in a stable distribution.

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.