1
0
mirror of https://github.com/altlinux/gpupdate.git synced 2025-03-21 18:50:38 +03:00

cups_applier: Use pycups to manage printer connection

This commit is contained in:
Игорь Чудов 2020-06-04 17:26:46 +04:00
parent 923bf039bf
commit 158240614f
Signed by untrusted user: nir
GPG Key ID: 0F3883600CAE7AAC

View File

@ -19,6 +19,8 @@
import logging
import os
import cups
from .applier_frontend import applier_frontend
from gpt.printers import json2printer
from util.rpm import is_rpm_installed
@ -37,7 +39,7 @@ def storage_get_printers(storage, sid):
return printers
def write_printer(prn):
def connect_printer(connection, prn):
'''
Dump printer cinfiguration to disk as CUPS config
'''
@ -48,6 +50,7 @@ def write_printer(prn):
class cups_applier(applier_frontend):
def __init__(self, storage):
self.storage = storage
self.cups_connection = cups.Connection()
def apply(self):
'''
@ -84,9 +87,10 @@ class cups_applier_user(applier_frontend):
logging.warning(slogm('CUPS is not installed: no printer settings will be deployed'))
return
self.cups_connection = cups.Connection()
printers = storage_get_printers(self.storage, self.sid)
if printers:
for prn in printers:
write_printer(prn)
connect_printer(self.cups_connection, prn)