Commit 4db575bf authored by Ben Morrice's avatar Ben Morrice
Browse files

Add check to reject incomplete LDAP data

parent e5a2b465
Pipeline #4169958 passed with stages
in 10 minutes and 26 seconds
......@@ -4,7 +4,7 @@
Summary: CERN LDAP printer database client and integration sctipts
Name: lpadmincern
Version: 1.4.2
Version: 1.4.3
Release: 1%{?dist}
Source0: %{name}-%{version}.tgz
Group: CERN/Utilities
......@@ -57,6 +57,9 @@ Additional scripts provide integration of local system
lp clients and CERN printing infrastructure.
%changelog
* Fri Jul 01 2022 Ben Morrice <ben.morrice@cern.ch> 1.4.3-1
- Add check to reject incomplete LDAP data
* Mon Jun 27 2022 Ben Morrice <ben.morrice@cern.ch> 1.4.2-1
- fix printer definition
......
......@@ -382,8 +382,12 @@ def main():
printerbindings = printer_driver_bindings(verbose)
allprinters = {}
for p in printer_results:
printer = {p[1]['printerName'].upper(): {'description': p[1]['description'], 'driver': 'GENERIC POSTSCRIPT PRINTER', 'ppdfile': printerbindings['Generic PostScript Printer'],
try:
printer = {p[1]['printerName'].upper(): {'description': p[1]['description'], 'driver': 'GENERIC POSTSCRIPT PRINTER', 'ppdfile': printerbindings['Generic PostScript Printer'],
'location': p[1]['location'].strip(), 'printColor': p[1]['printColor'], 'printDuplexSupported': p[1]['printDuplexSupported'], 'serverName': p[1]['serverName']}}
except KeyError:
print(f"Rejected data for: {p[1]['printerName'].upper()} (incomplete LDAP object).")
continue
for k in printerbindings.items():
if p[1]['description'].upper() in k[0].upper():
printer[p[1]['printerName'].upper()]['driver'] = k[0].upper()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment