mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
Remove the PPD file once read, otherwise they accumulate
This commit is contained in:
@@ -19,6 +19,8 @@
|
|||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
import cups
|
import cups
|
||||||
|
import errno
|
||||||
|
import os
|
||||||
|
|
||||||
from openerp import models, fields, api
|
from openerp import models, fields, api
|
||||||
|
|
||||||
@@ -35,12 +37,19 @@ class Printer(models.Model):
|
|||||||
vals = super(Printer, self)._prepare_update_from_cups(cups_connection,
|
vals = super(Printer, self)._prepare_update_from_cups(cups_connection,
|
||||||
cups_printer)
|
cups_printer)
|
||||||
|
|
||||||
ppd_file_path = cups_connection.getPPD3(self.system_name)
|
ppd_info = cups_connection.getPPD3(self.system_name)
|
||||||
if not ppd_file_path[2]:
|
ppd_path = ppd_info[2]
|
||||||
|
if not ppd_path:
|
||||||
return vals
|
return vals
|
||||||
|
|
||||||
ppd = cups.PPD(ppd_file_path[2])
|
ppd = cups.PPD(ppd_path)
|
||||||
option = ppd.findOption('InputSlot')
|
option = ppd.findOption('InputSlot')
|
||||||
|
try:
|
||||||
|
os.unlink(ppd_path)
|
||||||
|
except OSError as err:
|
||||||
|
if err.errno == errno.ENOENT:
|
||||||
|
pass
|
||||||
|
raise
|
||||||
if not option:
|
if not option:
|
||||||
return vals
|
return vals
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user