mirror of
https://github.com/altlinux/gpupdate.git
synced 2025-03-21 18:50:38 +03:00
gpt.gpt: Enable printer settings search
This commit is contained in:
parent
158240614f
commit
c0d82c6d22
@ -34,8 +34,7 @@ def storage_get_printers(storage, sid):
|
||||
printers = list()
|
||||
|
||||
for prnj in printer_objs:
|
||||
prn_obj = json2printer(prnj)
|
||||
printers.append(prn_obj)
|
||||
printers.append(prnj)
|
||||
|
||||
return printers
|
||||
|
||||
@ -43,9 +42,23 @@ def connect_printer(connection, prn):
|
||||
'''
|
||||
Dump printer cinfiguration to disk as CUPS config
|
||||
'''
|
||||
printer_config_path = os.path.join('/etc/cups', prn.name)
|
||||
with open(printer_config_path, 'r') as f:
|
||||
print(prn.cups_config(), file=f)
|
||||
# PPD file location
|
||||
printer_driver = 'generic'
|
||||
printer_parts = prn.printer['printer']['path'].partition(' ')
|
||||
# Printer queue name in CUPS
|
||||
printer_name = printer_parts[0]
|
||||
# Printer description in CUPS
|
||||
printer_info = printer_name
|
||||
printer_uri = printer_parts[2].replace('\\', '/')
|
||||
if printer_uri.startswith('//'):
|
||||
printer_uri = 'smb:' + printer_uri
|
||||
|
||||
connection.addPrinter(
|
||||
name=printer_name
|
||||
, info=printer_info
|
||||
, device=printer_uri
|
||||
#filename=printer_driver
|
||||
)
|
||||
|
||||
class cups_applier(applier_frontend):
|
||||
def __init__(self, storage):
|
||||
@ -60,11 +73,12 @@ class cups_applier(applier_frontend):
|
||||
logging.warning(slogm('CUPS is not installed: no printer settings will be deployed'))
|
||||
return
|
||||
|
||||
printers = storage_get_printers(self.storage, self.storage.get_info('machine_sid'))
|
||||
self.cups_connection = cups.Connection()
|
||||
self.printers = storage_get_printers(self.storage, self.storage.get_info('machine_sid'))
|
||||
|
||||
if printers:
|
||||
for prn in printers:
|
||||
write_printer(prn)
|
||||
if self.printers:
|
||||
for prn in self.printers:
|
||||
connect_printer(self.cups_connection, prn)
|
||||
|
||||
class cups_applier_user(applier_frontend):
|
||||
def __init__(self, storage, sid, username):
|
||||
@ -88,9 +102,9 @@ class cups_applier_user(applier_frontend):
|
||||
return
|
||||
|
||||
self.cups_connection = cups.Connection()
|
||||
printers = storage_get_printers(self.storage, self.sid)
|
||||
self.printers = storage_get_printers(self.storage, self.sid)
|
||||
|
||||
if printers:
|
||||
for prn in printers:
|
||||
if self.printers:
|
||||
for prn in self.printers:
|
||||
connect_printer(self.cups_connection, prn)
|
||||
|
||||
|
@ -161,7 +161,7 @@ class gpt:
|
||||
'shortcuts'
|
||||
, 'drives'
|
||||
, 'environmentvariables'
|
||||
#, 'printers'
|
||||
, 'printers'
|
||||
, 'folders'
|
||||
, 'files'
|
||||
, 'inifiles'
|
||||
|
Loading…
x
Reference in New Issue
Block a user