platypush.plugins.printer.cups

class platypush.plugins.printer.cups.PrinterCupsPlugin(host: str = 'localhost', printer: Optional[str] = None, **kwargs)[source]

A plugin to interact with a CUPS printer server.

Requires:

  • pycups (pip install pycups)
__init__(host: str = 'localhost', printer: Optional[str] = None, **kwargs)[source]
Parameters:
  • host – CUPS host IP/name (default: localhost).
  • printer – Default printer name that should be used.
accept_jobs(printer: Optional[str] = None, host: Optional[str] = None)[source]

Start accepting jobs on a printer.

Parameters:
  • printer – Printer name.
  • host – CUPS server IP/name (default: default configured host).
add_printer(name: str, ppd_file: str, info: str, location: Optional[str] = None, host: Optional[str] = None)[source]

Add a printer.

Parameters:
  • name – Printer name - alphanumeric + underscore characters only.
  • ppd_file – Path to the PPD file with the printer information and configuration.
  • host – CUPS server IP/name (default: default configured host).
  • info – Human-readable information about the printer.
  • location – Human-readable printer location info.
add_printer_to_class(printer_class: str, printer: Optional[str] = None, host: Optional[str] = None)[source]

Add a printer to a class.

Parameters:
  • printer_class – Class name.
  • printer – Printer name.
  • host – CUPS server IP/name (default: default configured host).
cancel_job(job_id: int, purge_job: bool = False, host: Optional[str] = None)[source]

Cancel a printer job.

Parameters:
  • job_id – Job ID to cancel.
  • purge_job – Also remove the job from the server (default: False).
  • host – CUPS server IP/name (default: default configured host).
delete_printer(printer: str, host: Optional[str] = None)[source]

Delete a printer from a CUPS server.

Parameters:
  • printer – Printer name.
  • host – CUPS server IP/name (default: default configured host).
delete_printer_from_class(printer_class: str, printer: Optional[str] = None, host: Optional[str] = None)[source]

Delete a printer from a class.

Parameters:
  • printer_class – Class name.
  • printer – Printer name.
  • host – CUPS server IP/name (default: default configured host).
disable_printer(printer: Optional[str] = None, host: Optional[str] = None)[source]

Disable a printer on a CUPS server.

Parameters:
  • printer – Printer name.
  • host – CUPS server IP/name (default: default configured host).
enable_printer(printer: Optional[str], host: Optional[str] = None)[source]

Enable a printer on a CUPS server.

Parameters:
  • printer – Printer name.
  • host – CUPS server IP/name (default: default configured host).
finish_document(printer: Optional[str] = None, host: Optional[str] = None)[source]

Finish sending a document to a printer.

Parameters:
  • printer – Printer name (default: default configured printer).
  • host – CUPS server IP/name (default: default configured host).
get_classes(host: Optional[str] = None) → Dict[str, Dict[str, Any]][source]

Get the list of classes on a CUPS server.

Parameters:host – CUPS server IP/name (default: default configured host).
Returns:dict - class_name -> class_info.
get_jobs(host: Optional[str] = None) → Dict[int, Dict[str, Any]][source]

Get the list of active jobs.

Parameters:host – CUPS server IP/name (default: default configured host).
Returns:A job_id -> job_info dict.
get_printers(host: Optional[str] = None) → platypush.message.response.printer.cups.PrintersResponse[source]

Get the list of printers registered on a CUPS server. :param host: CUPS server host IP/name (default: default configured host). :return: platypush.message.response.printer.cups.PrintersResponse, as a name -> attributes dict.

move_job(job_id: int, source_printer_uri: str, target_printer_uri: str, host: Optional[str] = None)[source]

Move a job to another printer/URI.

Parameters:
  • job_id – Job ID to cancel.
  • source_printer_uri – Source printer URI.
  • target_printer_uri – Target printer URI.
  • host – CUPS server IP/name (default: default configured host).
print_file(filename: str, printer: Optional[str] = None, host: Optional[str] = None, title: Optional[str] = None, options: Optional[Dict[str, Any]] = None) → platypush.message.response.printer.cups.PrinterJobAddedResponse[source]

Print a file.

Parameters:
  • filename – Path to the file to print.
  • printer – Printer name (default: default configured printer).
  • host – CUPS server IP/name (default: default configured host).
  • title – Print title.
  • options – Extra CUPS name->value options.
print_files(filenames: List[str], printer: Optional[str] = None, host: Optional[str] = None, title: Optional[str] = None, options: Optional[Dict[str, Any]] = None) → platypush.message.response.printer.cups.PrinterJobAddedResponse[source]

Print a list of files.

Parameters:
  • filenames – Paths to the files to print.
  • printer – Printer name (default: default configured printer).
  • host – CUPS server IP/name (default: default configured host).
  • title – Print title.
  • options – Extra CUPS name->value options.
print_test_page(printer: Optional[str] = None, host: Optional[str] = None) → platypush.message.response.printer.cups.PrinterJobAddedResponse[source]

Print the CUPS test page.

Parameters:
  • printer – Printer name (default: default configured printer).
  • host – CUPS server IP/name (default: default configured host).
reject_jobs(printer: Optional[str] = None, host: Optional[str] = None)[source]

Start rejecting jobs on a printer.

Parameters:
  • printer – Printer name.
  • host – CUPS server IP/name (default: default configured host).