x2go.backends.printing.file module

x2go.backends.printing.file.X2GoClientPrinting class is one of Python X2Go’s public API classes.

Retrieve an instance of this class from your x2go.client.X2GoClient instance.

Use this class in your Python X2Go based applications to access the »printing« configuration of your X2Go client application.

class x2go.backends.printing.file.X2GoClientPrinting(config_files=['/home/mike/.x2goclient/printing', '/etc/x2goclient/printing'], defaults={'print': {'command': 'lpr', 'stdin': False, 'ps': False, 'startcmd': False}, 'view': {'open': True, 'command': 'xdg-open'}, 'General': {'pdfview': True, 'showdialog': False}, 'CUPS': {'defaultprinter': 'PDF'}, 'save': {'folder': 'PDF'}}, client_instance=None, logger=None, loglevel=56)[source]

Bases: x2go.inifiles.X2GoIniFile

x2go.backends.printing.file.X2GoClientPrinting provides access to the X2Go ini-like file »printing« as stored in ~/.x2goclient/printing resp. globally /etc/x2goclient/printing.

An instance of x2go.backends.printing.file.X2GoClientPrinting is created on each incoming print job. This facilitates that on every print job the print action for this job is derived from the »printing« configuration file.

Thus, changes on the file are active for the next incoming print job.

config_files = []
get_print_action(reload=False, reinit=False, return_name=False)[source]

Return the print action described by the »printing« configuration file.

Parameters:
  • reload (bool) – reload the configuration file before retrieving the print action? (Default value = False)
  • reinit (bool) – re-detect the print action from what is stored in cache? (Default value = False)
  • return_name (bool) – return the print action name, not the class (Default value = False)
Returns:

the configured print action

Return type:

obj or str

get_property(print_property)[source]

Retrieve a printing property as mapped by the _print_property_map() dictionary.

Parameters:print_property (str) – a printing property
Returns:the stored value for <print_property>
Return type:str
Raises:X2GoClientPrintingException – if the printing property does not exist
print_action

Return the print action described by the »printing« configuration file.

This method has property status and wraps around the get_print_action()

Returns:Returns the print action object
Return type:obj or str
set_property(print_property, value)[source]

Set a printing property as mapped by the _print_property_map() dictionary.

Parameters:
  • print_property (str) – a printing property
  • value (str) – the value to be stored as <print_property>
Raises:

X2GoClientPrintingException – if the printing property does not exist or if there is a type mismatch

store_print_action(print_action, **print_properties)[source]

Accept a new print action configuration. This includes the print action itself (DIALOG, PDFVIEW, PDFSAVE, PRINT or PRINTCMD) and related printing properties as mapped by the _print_property_map() dictionary.

Parameters:
  • print_action (str) – the print action name
  • print_properties (dict) – the printing properties to set for the given print action