LpstatPrinters - command lpstat -p
¶
Parses the output of lpstat -p
, to get locally configured printers.
Current available printer states are:
IDLE (
PRINTER_STATUS_IDLE
)PROCESSING (
PRINTER_STATUS_PROCESSING
) -- printingDISABLED (
PRINTER_STATUS_DISABLED
)UNKNOWN (
PRINTER_STATUS_UNKNOWN
)
Examples
>>> from insights.parsers.lpstat import LpstatPrinters, PRINTER_STATUS_DISABLED
>>> from insights.tests import context_wrap
>>> LPSTAT_P_OUTPUT = '''
... printer idle_printer is idle. enabled since Fri 20 Jan 2017 09:55:50 PM CET
... printer disabled_printer disabled since Wed 15 Feb 2017 12:01:11 PM EST -
... reason unknown
... '''
>>> lpstat = LpstatPrinters(context_wrap(LPSTAT_P_OUTPUT))
>>> lpstat.printers
[{'status': 'IDLE', 'name': 'idle_printer'}, {'status': 'DISABLED', 'name': 'disabled_printer'}]
>>> lpstat.printer_names_by_status(PRINTER_STATUS_DISABLED)
['disabled_printer']
-
class
insights.parsers.lpstat.
LpstatPrinters
(*args, **kwargs)[source]¶ Bases:
insights.core.CommandParser
Class to parse
lpstat -p
command output.- Raises
ValueError -- Raised if any error occurs parsing the content.
-
printer_names_by_status
(status)[source]¶ Gives names of configured printers for a given status
- Parameters
status (string) --
-
printers
= None¶ Dictionary of locally configured printers, with keys ‘name’ and ‘status’
- Type
dict