Plugins

Package with routines to access the plugins (Python modules) stored in the current subdirectory.

Usage:

plugins(args_for_names_function)
get_functions(plugin_name)(args_for_plugin_function)
call_functions(plugin_name, args_for_plugin_function)

ESC & ESC/P2 converter

Watchdog for /ps directory that is able to convert new files into pdfs

Conversions are made thanks to Escapy.

As soon as a file is closed, a pdf is created.

Expected config:

  • misc: emulation + endlesstext: epson/auto + no

  • esc: preferred_backend: escapy

class libreprinter.plugins.lp_escapy_converter.EscapyEventHandler(settings: SectionProxy | dict, *args, **kwargs)[source]

Watch a directory via a parent Observer and emit events accordingly

This class only reimplements on_closed() event.

Watched directory:

  • raw: *.raw

Attribute:
param settings:

Escapy Section of the current ConfigParser.

type settings:

configparser.SectionProxy | dict

Class attribute:
param FILES_REGEX:

Patterns to detect raw files.

type FILES_REGEX:

list[str]

build_command(src_path: Path)[source]

Build argument list

Note

Think about further support for: –pins –single_sheets, –no-single_sheets

on_closed(event)[source]

File closing is detected, convert it to PDF

Minimal command:

escapy ./raw/file.raw                 -db user_characters_db/mappings.json                 -o pdf/file.pdf                 -c /etc/escapy/escapy.conf
libreprinter.plugins.lp_escapy_converter.configure_escapy(config: ConfigParser)[source]

Check and set default configuration values for the current plugin

Parameters:

config – Opened ConfigParser object

libreprinter.plugins.lp_escapy_converter.setup_escapy_watchdog(config: ConfigParser | dict)[source]

Initialise a watchdog on /raw directory in configured output_path.

Any raw file created in this directories will be converted in /pdf by the Escapy program installed on the system.

Data & PDF to Printer

Watchdog for /pdf directory that is able to sent new files to a printer

Send new pdfs files on a printer configured in Cups.

Expected settings: output_printer set and not *stream as endlesstext setting; i.e. output_printer is defined; and it is not an infinite stream.

In other terms, a pdf is sent to printer if:

  • endlesstext setting is no, plain-jobs, strip-escp2-jobs,

  • and output_printer setting is not no

TODO: only “no” for endless config because strip wrongly builds empty pdf files

=> not any of (“plain-jobs”, “strip-escp2-jobs”, “no”)

class libreprinter.plugins.lp_jobs_to_printer_watchdog.PdfEventHandler(*args, printer_name=None, **kwargs)[source]

Watch a directory via a parent Observer and emit events accordingly

This class only reimplements on_closed() event.

Watched directories:

  • pdf: *.pdf

Attribute:
param printer_name:

Name of the CUPS printer which will receive files as jobs.

type printer_name:

str

Class attribute:
param FILES_REGEX:

Patterns to detect pdf files.

type FILES_REGEX:

list[str]

on_closed(event)[source]

PDF creation is detected, send it to the configured printer

libreprinter.plugins.lp_jobs_to_printer_watchdog.setup_pdf_watchdog(config)[source]

Initialise a watchdog on /pdf directory in configured output_path.

Any pdf file created in these directories will be sent to the printer configured via output_printer.

Returns:

Observer that is currently watching directories.

Return type:

watchdog.Observer

PCL to PDF

Watchdog for /pcl directory that is able to convert new files into pdfs

The conversion is made thanks to the pcl_converter_path setting pointing to the GhostPCL binary.

class libreprinter.plugins.lp_pcl_to_pdf_watchdog.PclEventHandler(converter_path, *args, **kwargs)[source]

Watch a directory via a parent Observer and emit events accordingly

This class only reimplements on_closed() event.

Watched directory:

  • pcl: *.pcl

Attribute:
param converter_path:

Path to GhostPCL binary.

type converter_path:

str

Class attribute:
param FILES_REGEX:

Patterns to detect pcl files.

type FILES_REGEX:

list[str]

on_closed(event)[source]

PCL file creation is detected, convert it to PDF

libreprinter.plugins.lp_pcl_to_pdf_watchdog.setup_pcl_watchdog(config)[source]

Initialise a watchdog on /pcl directory in configured output_path.

Any pcl file created in this directories will be converted in /pdf by the ghostpcl binary whose path is indicated in the variable pcl_converter_path.

Returns:

Observer that is currently watching directories.

Return type:

watchdog.Observer

HPGL to PDF

Watchdog for /hpgl directory that is able to convert new files into pdfs

Conversions are made thanks to Hp2xx & Ghostscript.

As soon as a hpgl file is created, a pdf is created.

Expected config (emulation + endlesstext):

  • hpgl + no

class libreprinter.plugins.lp_hpgl_converter.HpglEventHandler(hp2xx_path, *args, hp2xx_settings='', **kwargs)[source]

Watch a directory via a parent Observer and emit events accordingly

This class only reimplements on_closed() event.

Watched directory:

  • hpgl: *.hpgl

Attributes:
param hp2xx_path:

Path to the Hp2xx binary.

param hp2xx_settings:

Command line settings for Hp2xx binary.

type hp2xx_path:

str

type hp2xx_settings:

str

Class attribute:
param FILES_REGEX:

Patterns to detect txt files.

type FILES_REGEX:

list[str]

on_closed(event)[source]

File closing is detected, convert it to PDF

Minimal command:

hp2xx -m eps -q -t -f out.ps in.hpgl
libreprinter.plugins.lp_hpgl_converter.setup_hpgl_watchdog(config)[source]

Initialise a watchdog on /hpgl directory in configured output_path.

Any hpgl file created in this directories will be converted in /pdf by the Hp2xx & Ghostscript binaries installed on the system.

PostScript to PDF

Watchdog for /ps directory that is able to convert new files into pdfs

Conversions from PostScript are made thanks to Ghostscript.

As soon as a file is closed, a pdf is created.

Expected config (emulation + endlesstext):

  • postscript + no

class libreprinter.plugins.lp_ps_converter.PostscriptEventHandler(*args, gs_settings=None, **kwargs)[source]

Watch a directory via a parent Observer and emit events accordingly

This class only reimplements on_closed() event.

Watched directory:

  • ps: *.ps

Attribute:
param gs_settings:

Command line settings for Ghostscript binary.

type gs_settings:

list[str] or None

Class attribute:
param FILES_REGEX:

Patterns to detect PostScript files.

type FILES_REGEX:

list[str]

on_closed(event)[source]

File closing is detected, convert it to PDF

Minimal command:

gs -sDEVICE=pdfwrite -o out.pdf in.ps
libreprinter.plugins.lp_ps_converter.setup_postscript_watchdog(config)[source]

Initialise a watchdog on /ps directory in configured output_path.

Any ps file created in this directories will be converted in /pdf by the Ghostscript binary installed on the system.

Text to PDF

Watchdog for /txt_jobs directory that is able to convert new files into pdfs

Conversions are made thanks to Enscript & Ghostscript.

As soon as a txt file is created, a pdf is created.

Expected config (emulation + endlesstext):

  • epson + plain-jobs

  • epson + strip-escp2-jobs

  • text + no

Yes the following config targets also: epson + no, text + plain-jobs but in the first case there will be no text file, and in the 2nd case there will be a text file due to text (plain-jobs is only for epson emulations).

So… The plugin is not compatible with hp emulation, nor with *stream in endlesstext setting.

class libreprinter.plugins.lp_txt_converter.TxtEventHandler(settings: SectionProxy | dict, *args, **kwargs)[source]

Watch a directory via a parent Observer and emit events accordingly

This class only reimplement on_closed() event.

Watched directory:

  • txt_jobs: *.txt

Attributes:
param settings:

Escapy Section of the current ConfigParser.

type settings:

configparser.SectionProxy | dict

Class attribute:
param FILES_REGEX:

Patterns to detect txt files.

type FILES_REGEX:

list[str]

on_closed(event)[source]

File closing is detected, convert it to PDF

Minimal command:

enscript -R -p - input_tty_generator.py | gs -sDEVICE=pdfwrite -o out.pdf -
libreprinter.plugins.lp_txt_converter.configure_text(config: ConfigParser)[source]

Check and set default configuration values for the current plugin

Parameters:

config – Opened ConfigParser object

libreprinter.plugins.lp_txt_converter.setup_text_watchdog(config)[source]

Initialise a watchdog on /txt_jobs directory in configured output_path.

Any txt file created in this directories will be converted in /pdf by the Enscript & Ghostscript binaries installed on the system.

Seiko Qt-2100 Timegrapher to PDF & CSV

Watchdog for /raw directory that is able to parse & convert new files into CSV and/or into pdfs

Conversions are made thanks to Seiko-converter.

As soon as a raw file is modified or closed, a pdf is created. This allows to always have the latest data available even with long gate modes configured on the QT-2100 device.

class libreprinter.plugins.lp_seiko_qt2100_converter.SeikoEventHandler(*args, seiko_settings=None, **kwargs)[source]

Watch a directory via a parent Observer and emit events accordingly

This class reimplements on_closed + :meth:`on_modified() events.

Watched directory:

  • raw: *.raw

Attributes:
param seiko_settings:

Settings of the seiko-qt2100 section from the config file.

param last_timestamp:

Keep the timestamp of the last modified file event. Used to reduce overhead.

type seiko_settings:

dict

type last_timestamp:

float

Class attribute:
param FILES_REGEX:

Patterns to detect files.

type FILES_REGEX:

list[str]

build_data(event)[source]

Generate csv and/or pdf files according to the config file specs

on_closed(event)[source]

File creation is detected, generate full files

on_modified(event: FileSystemEvent) None[source]

File is modified, generate partial files

libreprinter.plugins.lp_seiko_qt2100_converter.configure_seiko(config)[source]

Check and set default configuration values for the current plugin

Parameters:

config (configparser.ConfigParser) – Opened ConfigParser object

libreprinter.plugins.lp_seiko_qt2100_converter.setup_seiko_watchdog(config)[source]

Initialise a watchdog on /raw directory in configured output_path.

Any raw file created in this directory will be converted in /pdf or /csv by the seiko-converter Python program installed on the system.