Skip to content

Commit 6e317e4

Browse files
committed
Use remote server ppd file, in case a printer has been shared via cups.
1 parent 83856b9 commit 6e317e4

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

newprinter.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,11 +1454,22 @@ def _selectDeviceForInstallation (self, uri):
14541454
else:
14551455
port = 631
14561456
try:
1457+
debugprint('Download ppd file from remote server')
14571458
conn = http.client.HTTPConnection(resg[0], port)
14581459
conn.request("GET", "/printers/%s.ppd" % resg[2])
14591460
resp = conn.getresponse()
14601461
if resp.status == 200:
14611462
self.remotecupsqueue = resg[2]
1463+
1464+
ppdcontent = resp.read()
1465+
1466+
with tempfile.NamedTemporaryFile () as tmpf:
1467+
tmpf.write(ppdcontent)
1468+
tmpf.flush()
1469+
try:
1470+
ppd = cups.PPD(tmpf.name)
1471+
except (cups.IPPError, RuntimeError):
1472+
raise IOError("Server's ppd file is corrupted.")
14621473
except:
14631474
pass
14641475

@@ -1549,8 +1560,9 @@ def _installPrinterFromDeviceID (self, devid, page_nr, step):
15491560
elif self.remotecupsqueue:
15501561
# We have a remote CUPS queue, let the client queue
15511562
# stay raw so that the driver on the server gets used
1552-
ppdname = 'raw'
1553-
self.ppd = ppdname
1563+
if self.ppd is None:
1564+
ppdname = 'raw'
1565+
self.ppd = ppdname
15541566
name = self.remotecupsqueue
15551567
name = self.makeNameUnique (name)
15561568
self.entNPName.set_text (name)

0 commit comments

Comments
 (0)