Lpstat - command lpstat

Parsers contains in this module are:

LpstatPrinters - command /usr/bin/lpstat -p

LpstatProtocol - command /usr/bin/lpstat -v

class insights.parsers.lpstat.LpstatPrinters(*args, **kwargs)[source]

Bases: insights.core.CommandParser

Class to parse lpstat -p command output. Parses the output of lpstat -p, to get locally configured printers. Current available printer states are:

  • IDLE (PRINTER_STATUS_IDLE)

  • PROCESSING (PRINTER_STATUS_PROCESSING) -- printing

  • DISABLED (PRINTER_STATUS_DISABLED)

  • UNKNOWN (PRINTER_STATUS_UNKNOWN)

Sample output of the command:

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

Raises

ValueError -- Raised if any error occurs parsing the content.

Examples: >>> type(lpstat_printers) <class ‘insights.parsers.lpstat.LpstatPrinters’> >>> len(lpstat_printers.printers) 3 >>> lpstat_printers.printer_names_by_status(‘DISABLED’) [‘disabled_printer’]

parse_content(content)[source]

This method must be implemented by classes based on this class.

printer_names_by_status(status)[source]

Gives names of configured printers for a given status

Parameters

status (string) --

printers

Dictionary of locally configured printers, with keys ‘name’ and ‘status’

Type

dict

class insights.parsers.lpstat.LpstatProtocol(context, extra_bad_lines=None)[source]

Bases: insights.core.CommandParser, dict

Class to parse lpstat -v command output.

Sample output of the command:

device for test_printer1: ipp
device for test_printer2: ipp

Examples

>>> type(lpstat_protocol)
<class 'insights.parsers.lpstat.LpstatProtocol'>
>>> lpstat_protocol['test_printer1']
'ipp'
parse_content(content)[source]

This method must be implemented by classes based on this class.