[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Trouble setting up hplip and cups - printer ppd fails
From: |
Danny Milosavljevic |
Subject: |
Re: Trouble setting up hplip and cups - printer ppd fails |
Date: |
Sat, 24 Dec 2016 16:23:00 +0100 |
Hi,
On Sat, 24 Dec 2016 14:08:44 +0000
ng0 <address@hidden> wrote:
> > Traceback (most recent call last):
> > File
> > "/gnu/store/95vp3r6n9z7s85achc7a0b8aay1k73qq-hplip-3.16.11/share/hplip/setup.py",
> > line 560, in <module>
> > desc = nickname_pat.search(nickname).group(1)
> > TypeError: cannot use a string pattern on a bytes-like object
The reason that fails is because gzip.GzipFile always provides reads in binary
mode. However, ppd files are not binary and nickname_pat is not binary either.
So not sure what they were thinking...
if file_path.endswith('.gz'):
nickname = gzip.GzipFile(file_path,
'r').read(4096) # bytes, not str
else:
nickname = open(file_path, 'r').read(4096) # str
try:
desc = nickname_pat.search(nickname).group(1)
except AttributeError:
desc = ''
A quick fix would be to gunzip the ppd file and specify it without ".gz" in
hp-setup. You don't need to patch anything for this.
A better fix with patching would be: Replacing
nickname = gzip.GzipFile(file_path,
'r').read(4096)
by
nickname = gzip.GzipFile(file_path,
'r').read(4096).decode("utf-8")
.
An even better fix would be to find out which parts are supposed to be binary
and which are supposed to be text - use the correct functions accordingly and
upstream it.