The branch, twofactorauth has been updated via f23de90610279b2cf45ea1f0e796d6d6bf1d3d0e (commit) from f39ec248133fcde426879c1a5480578e0aee8a25 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: debian/pycompat | 1 - x2go/__init__.py | 4 +- x2go/backends/control/__init__.py | 9 +- x2go/backends/control/{stdout.py => _stdout.py} | 0 x2go/backends/info/__init__.py | 12 +-- x2go/backends/info/{stdout.py => _stdout.py} | 0 x2go/backends/{control => printing}/__init__.py | 10 +- x2go/backends/printing/_file.py | 113 ++++++++++++++++++++ x2go/backends/printing/_gconf.py | 113 ++++++++++++++++++++ x2go/backends/printing/_httpsbroker.py | 113 ++++++++++++++++++++ x2go/backends/printing/_winreg.py | 113 ++++++++++++++++++++ x2go/backends/profiles/__init__.py | 11 +- .../profiles/{sessions_file.py => _file.py} | 0 .../profiles/{win_registry.py => _gconf.py} | 2 +- .../profiles/{https_broker.py => _httpsbroker.py} | 2 +- .../profiles/{win_registry.py => _winreg.py} | 0 x2go/backends/proxy/__init__.py | 6 +- x2go/backends/proxy/{nx3.py => _nx3.py} | 0 x2go/backends/{profiles => settings}/__init__.py | 11 +- x2go/{settings.py => backends/settings/_file.py} | 14 +-- x2go/{settings.py => backends/settings/_gconf.py} | 14 +-- .../settings/_httpsbroker.py} | 14 +-- x2go/{settings.py => backends/settings/_winreg.py} | 14 +-- x2go/backends/terminal/__init__.py | 6 +- x2go/backends/terminal/{stdout.py => _stdout.py} | 0 x2go/client.py | 52 ++++++--- x2go/defaults.py | 50 +++++++-- x2go/registry.py | 23 ++-- 28 files changed, 610 insertions(+), 97 deletions(-) delete mode 100644 debian/pycompat rename x2go/backends/control/{stdout.py => _stdout.py} (100%) rename x2go/backends/info/{stdout.py => _stdout.py} (100%) copy x2go/backends/{control => printing}/__init__.py (76%) create mode 100644 x2go/backends/printing/_file.py create mode 100644 x2go/backends/printing/_gconf.py create mode 100644 x2go/backends/printing/_httpsbroker.py create mode 100644 x2go/backends/printing/_winreg.py rename x2go/backends/profiles/{sessions_file.py => _file.py} (100%) copy x2go/backends/profiles/{win_registry.py => _gconf.py} (99%) rename x2go/backends/profiles/{https_broker.py => _httpsbroker.py} (99%) rename x2go/backends/profiles/{win_registry.py => _winreg.py} (100%) rename x2go/backends/proxy/{nx3.py => _nx3.py} (100%) copy x2go/backends/{profiles => settings}/__init__.py (72%) copy x2go/{settings.py => backends/settings/_file.py} (82%) copy x2go/{settings.py => backends/settings/_gconf.py} (82%) copy x2go/{settings.py => backends/settings/_httpsbroker.py} (82%) rename x2go/{settings.py => backends/settings/_winreg.py} (82%) rename x2go/backends/terminal/{stdout.py => _stdout.py} (100%) The diff of changes is: diff --git a/debian/pycompat b/debian/pycompat deleted file mode 100644 index 0c043f1..0000000 --- a/debian/pycompat +++ /dev/null @@ -1 +0,0 @@ -2.6- diff --git a/x2go/__init__.py b/x2go/__init__.py index 05417c6..a2c5c82 100644 --- a/x2go/__init__.py +++ b/x2go/__init__.py @@ -167,8 +167,8 @@ _signal.signal (_signal.SIGINT, guardian._sigterm_handle ) from client import X2goClient from backends.profiles import X2goSessionProfiles -from printing import X2goClientPrinting -from settings import X2goClientSettings +from backends.printing import X2goClientPrinting +from backends.settings import X2goClientSettings from x2go_exceptions import * from log import * diff --git a/x2go/backends/control/__init__.py b/x2go/backends/control/__init__.py index e7780c4..fb83b48 100644 --- a/x2go/backends/control/__init__.py +++ b/x2go/backends/control/__init__.py @@ -17,11 +17,8 @@ # Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. -from gevent import monkey -monkey.patch_all() +from x2go.defaults import BACKEND_CONTROLSESSION_DEFAULT -from x2go.defaults import DEFAULT_CONTROLSESSION_BACKEND +from _stdout import X2goControlSessionSTDOUT -from stdout import X2goControlSessionSTDOUT - -X2goControlSession = eval(DEFAULT_CONTROLSESSION_BACKEND) +X2goControlSession = eval(BACKEND_CONTROLSESSION_DEFAULT) diff --git a/x2go/backends/control/stdout.py b/x2go/backends/control/_stdout.py similarity index 100% rename from x2go/backends/control/stdout.py rename to x2go/backends/control/_stdout.py diff --git a/x2go/backends/info/__init__.py b/x2go/backends/info/__init__.py index 0606d7b..4a27bfd 100644 --- a/x2go/backends/info/__init__.py +++ b/x2go/backends/info/__init__.py @@ -17,11 +17,11 @@ # Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. -from x2go.defaults import DEFAULT_SERVERSESSIONINFO_BACKEND -from x2go.defaults import DEFAULT_SERVERSESSIONLIST_BACKEND +from x2go.defaults import BACKEND_SERVERSESSIONINFO_DEFAULT +from x2go.defaults import BACKEND_SERVERSESSIONLIST_DEFAULT -from stdout import X2goServerSessionInfoSTDOUT -from stdout import X2goServerSessionListSTDOUT +from _stdout import X2goServerSessionInfoSTDOUT +from _stdout import X2goServerSessionListSTDOUT -X2goServerSessionInfo = eval(DEFAULT_SERVERSESSIONINFO_BACKEND) -X2goServerSessionList = eval(DEFAULT_SERVERSESSIONLIST_BACKEND) +X2goServerSessionInfo = eval(BACKEND_SERVERSESSIONINFO_DEFAULT) +X2goServerSessionList = eval(BACKEND_SERVERSESSIONLIST_DEFAULT) diff --git a/x2go/backends/info/stdout.py b/x2go/backends/info/_stdout.py similarity index 100% rename from x2go/backends/info/stdout.py rename to x2go/backends/info/_stdout.py diff --git a/x2go/backends/control/__init__.py b/x2go/backends/printing/__init__.py similarity index 76% copy from x2go/backends/control/__init__.py copy to x2go/backends/printing/__init__.py index e7780c4..683b424 100644 --- a/x2go/backends/control/__init__.py +++ b/x2go/backends/printing/__init__.py @@ -17,11 +17,11 @@ # Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. -from gevent import monkey -monkey.patch_all() +from x2go.defaults import BACKEND_CLIENTPRINTING_DEFAULT -from x2go.defaults import DEFAULT_CONTROLSESSION_BACKEND +from _file import X2goClientPrintingFILE +from _winreg import X2goClientPrintingWINREG +from _gconf import X2goClientPrintingGCONF -from stdout import X2goControlSessionSTDOUT +X2goClientPrinting = eval(BACKEND_CLIENTPRINTING_DEFAULT) -X2goControlSession = eval(DEFAULT_CONTROLSESSION_BACKEND) diff --git a/x2go/backends/printing/_file.py b/x2go/backends/printing/_file.py new file mode 100644 index 0000000..a17a84d --- /dev/null +++ b/x2go/backends/printing/_file.py @@ -0,0 +1,113 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Copyright (C) 2010 by Mike Gabriel <m.gabriel@das-netzwerkteam.de> +# +# Python X2go is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Python X2go is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + +"""\ +L{X2goClientPrintingFILE} class is one of Python X2go's public API classes. + +Retrieve an instance of this class from your L{X2goClient} instance. +Use this class in your Python X2go based applications to access the »printing« +configuration of your X2go client application. + +""" +__NAME__ = 'x2goprint-pylib' + +# modules +import types +import ConfigParser + +# Python X2go modules +import x2go.log as log +import x2go.printing as printing +# we hide the default values from epydoc (that's why we transform them to _UNDERSCORE variables) +from x2go.defaults import X2GO_CLIENTPRINTING_DEFAULTS as _X2GO_CLIENTPRINTING_DEFAULTS +from x2go.defaults import X2GO_PRINTING_CONFIGFILES as _X2GO_PRINTING_CONFIGFILES +import x2go.inifiles as inifiles + +class X2goClientPrintingFILE(inifiles.X2goIniFile): + """\ + L{X2goClientPrinting} provides access to the X2go ini-like file + »printing« as stored in C{~/.x2goclient/printing} resp. globally + C{/etc/x2goclient/printing}. + + An instance of L{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 = [] + _print_action = None + defaultValues = _X2GO_CLIENTPRINTING_DEFAULTS + + def __init__(self, config_files=_X2GO_PRINTING_CONFIGFILES, defaults=None, logger=None, loglevel=log.loglevel_DEFAULT): + """\ + @param config_files: a list of configuration files names (e.g. a global filename and a user's home + directory filename) + @type config_files: C{list} + @param defaults: a cascaded Python dicitionary structure with ini file defaults (to override + Python X2go's hard coded defaults in L{defaults} + @type defaults: C{dict} + @param logger: you can pass an L{X2goLogger} object to the + L{X2goPrintAction} constructor + @type logger: C{instance} + @param loglevel: if no L{X2goLogger} object has been supplied a new one will be + constructed with the given loglevel + @type loglevel: C{int} + + """ + inifiles.X2goIniFile.__init__(self, config_files, defaults=defaults, logger=logger, loglevel=loglevel) + + self._detect_print_action() + + + def _detect_print_action(self): + """\ + Derive a print action from sections, keys and their values in a typical + X2go client »printing« configuration file. + + """ + _general_pdfview = self.get('General', 'pdfview', key_type=types.BooleanType) + _view_open = self.get('view', 'open', key_type=types.BooleanType) + _print_startcmd = self.get('print', 'startcmd', key_type=types.BooleanType) + + if _general_pdfview and _view_open: + _view_command = self.get('view', 'command') + self._print_action = printing.X2goPrintActionPDFVIEW(pdfview_cmd=_view_command, logger=self.logger) + + elif _general_pdfview and not _view_open: + self._print_action = printing.X2goPrintActionPDFSAVE(logger=self.logger) + + elif not _general_pdfview and not _print_startcmd: + _cups_defaultprinter = self.get('CUPS', 'defaultprinter') + self._print_action = printing.X2goPrintActionPRINT(printer=_cups_defaultprinter, logger=self.logger) + + elif not _general_pdfview and _print_startcmd: + _print_command = self.get('print', 'command') + self._print_action = printing.X2goPrintActionPRINTCMD(print_cmd=_print_command, logger=self.logger) + + @property + def print_action(self): + """\ + Return the print action described by the »printing« configuration file. + + """ + return self._print_action + diff --git a/x2go/backends/printing/_gconf.py b/x2go/backends/printing/_gconf.py new file mode 100644 index 0000000..e869423 --- /dev/null +++ b/x2go/backends/printing/_gconf.py @@ -0,0 +1,113 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Copyright (C) 2010 by Mike Gabriel <m.gabriel@das-netzwerkteam.de> +# +# Python X2go is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Python X2go is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + +"""\ +L{X2goClientPrintingGCONF} class is one of Python X2go's public API classes. + +Retrieve an instance of this class from your L{X2goClient} instance. +Use this class in your Python X2go based applications to access the »printing« +configuration of your X2go client application. + +""" +__NAME__ = 'x2goprint-pylib' + +# modules +import types +import ConfigParser + +# Python X2go modules +import x2go.log as log +import x2go.printing as printing +# we hide the default values from epydoc (that's why we transform them to _UNDERSCORE variables) +from x2go.defaults import X2GO_CLIENTPRINTING_DEFAULTS as _X2GO_CLIENTPRINTING_DEFAULTS +from x2go.defaults import X2GO_PRINTING_CONFIGFILES as _X2GO_PRINTING_CONFIGFILES +import x2go.inifiles as inifiles + +class X2goClientPrintingGCONF(inifiles.X2goIniFile): + """\ + L{X2goClientPrinting} provides access to the X2go ini-like file + »printing« as stored in C{~/.x2goclient/printing} resp. globally + C{/etc/x2goclient/printing}. + + An instance of L{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 = [] + _print_action = None + defaultValues = _X2GO_CLIENTPRINTING_DEFAULTS + + def __init__(self, config_files=_X2GO_PRINTING_CONFIGFILES, defaults=None, logger=None, loglevel=log.loglevel_DEFAULT): + """\ + @param config_files: a list of configuration files names (e.g. a global filename and a user's home + directory filename) + @type config_files: C{list} + @param defaults: a cascaded Python dicitionary structure with ini file defaults (to override + Python X2go's hard coded defaults in L{defaults} + @type defaults: C{dict} + @param logger: you can pass an L{X2goLogger} object to the + L{X2goPrintAction} constructor + @type logger: C{instance} + @param loglevel: if no L{X2goLogger} object has been supplied a new one will be + constructed with the given loglevel + @type loglevel: C{int} + + """ + inifiles.X2goIniFile.__init__(self, config_files, defaults=defaults, logger=logger, loglevel=loglevel) + + self._detect_print_action() + + + def _detect_print_action(self): + """\ + Derive a print action from sections, keys and their values in a typical + X2go client »printing« configuration file. + + """ + _general_pdfview = self.get('General', 'pdfview', key_type=types.BooleanType) + _view_open = self.get('view', 'open', key_type=types.BooleanType) + _print_startcmd = self.get('print', 'startcmd', key_type=types.BooleanType) + + if _general_pdfview and _view_open: + _view_command = self.get('view', 'command') + self._print_action = printing.X2goPrintActionPDFVIEW(pdfview_cmd=_view_command, logger=self.logger) + + elif _general_pdfview and not _view_open: + self._print_action = printing.X2goPrintActionPDFSAVE(logger=self.logger) + + elif not _general_pdfview and not _print_startcmd: + _cups_defaultprinter = self.get('CUPS', 'defaultprinter') + self._print_action = printing.X2goPrintActionPRINT(printer=_cups_defaultprinter, logger=self.logger) + + elif not _general_pdfview and _print_startcmd: + _print_command = self.get('print', 'command') + self._print_action = printing.X2goPrintActionPRINTCMD(print_cmd=_print_command, logger=self.logger) + + @property + def print_action(self): + """\ + Return the print action described by the »printing« configuration file. + + """ + return self._print_action + diff --git a/x2go/backends/printing/_httpsbroker.py b/x2go/backends/printing/_httpsbroker.py new file mode 100644 index 0000000..830f134 --- /dev/null +++ b/x2go/backends/printing/_httpsbroker.py @@ -0,0 +1,113 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Copyright (C) 2010 by Mike Gabriel <m.gabriel@das-netzwerkteam.de> +# +# Python X2go is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Python X2go is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + +"""\ +L{X2goClientPrintingWINREG} class is one of Python X2go's public API classes. + +Retrieve an instance of this class from your L{X2goClient} instance. +Use this class in your Python X2go based applications to access the »printing« +configuration of your X2go client application. + +""" +__NAME__ = 'x2goprint-pylib' + +# modules +import types +import ConfigParser + +# Python X2go modules +import x2go.log as log +import x2go.printing as printing +# we hide the default values from epydoc (that's why we transform them to _UNDERSCORE variables) +from x2go.defaults import X2GO_CLIENTPRINTING_DEFAULTS as _X2GO_CLIENTPRINTING_DEFAULTS +from x2go.defaults import X2GO_PRINTING_CONFIGFILES as _X2GO_PRINTING_CONFIGFILES +import x2go.inifiles as inifiles + +class X2goClientPrintingWINREG(inifiles.X2goIniFile): + """\ + L{X2goClientPrinting} provides access to the X2go ini-like file + »printing« as stored in C{~/.x2goclient/printing} resp. globally + C{/etc/x2goclient/printing}. + + An instance of L{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 = [] + _print_action = None + defaultValues = _X2GO_CLIENTPRINTING_DEFAULTS + + def __init__(self, config_files=_X2GO_PRINTING_CONFIGFILES, defaults=None, logger=None, loglevel=log.loglevel_DEFAULT): + """\ + @param config_files: a list of configuration files names (e.g. a global filename and a user's home + directory filename) + @type config_files: C{list} + @param defaults: a cascaded Python dicitionary structure with ini file defaults (to override + Python X2go's hard coded defaults in L{defaults} + @type defaults: C{dict} + @param logger: you can pass an L{X2goLogger} object to the + L{X2goPrintAction} constructor + @type logger: C{instance} + @param loglevel: if no L{X2goLogger} object has been supplied a new one will be + constructed with the given loglevel + @type loglevel: C{int} + + """ + inifiles.X2goIniFile.__init__(self, config_files, defaults=defaults, logger=logger, loglevel=loglevel) + + self._detect_print_action() + + + def _detect_print_action(self): + """\ + Derive a print action from sections, keys and their values in a typical + X2go client »printing« configuration file. + + """ + _general_pdfview = self.get('General', 'pdfview', key_type=types.BooleanType) + _view_open = self.get('view', 'open', key_type=types.BooleanType) + _print_startcmd = self.get('print', 'startcmd', key_type=types.BooleanType) + + if _general_pdfview and _view_open: + _view_command = self.get('view', 'command') + self._print_action = printing.X2goPrintActionPDFVIEW(pdfview_cmd=_view_command, logger=self.logger) + + elif _general_pdfview and not _view_open: + self._print_action = printing.X2goPrintActionPDFSAVE(logger=self.logger) + + elif not _general_pdfview and not _print_startcmd: + _cups_defaultprinter = self.get('CUPS', 'defaultprinter') + self._print_action = printing.X2goPrintActionPRINT(printer=_cups_defaultprinter, logger=self.logger) + + elif not _general_pdfview and _print_startcmd: + _print_command = self.get('print', 'command') + self._print_action = printing.X2goPrintActionPRINTCMD(print_cmd=_print_command, logger=self.logger) + + @property + def print_action(self): + """\ + Return the print action described by the »printing« configuration file. + + """ + return self._print_action + diff --git a/x2go/backends/printing/_winreg.py b/x2go/backends/printing/_winreg.py new file mode 100644 index 0000000..1ced8ef --- /dev/null +++ b/x2go/backends/printing/_winreg.py @@ -0,0 +1,113 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Copyright (C) 2010 by Mike Gabriel <m.gabriel@das-netzwerkteam.de> +# +# Python X2go is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Python X2go is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + +"""\ +L{X2goClientPrintingWINREG} class is one of Python X2go's public API classes. + +Retrieve an instance of this class from your L{X2goClient} instance. +Use this class in your Python X2go based applications to access the »printing« +configuration of your X2go client application. + +""" +__NAME__ = 'x2goprint-pylib' + +# modules +import types +import ConfigParser + +# Python X2go modules +import x2go.log as log +import x2go.printing as printingB +# we hide the default values from epydoc (that's why we transform them to _UNDERSCORE variables) +from x2go.defaults import X2GO_CLIENTPRINTING_DEFAULTS as _X2GO_CLIENTPRINTING_DEFAULTS +from x2go.defaults import X2GO_PRINTING_CONFIGFILES as _X2GO_PRINTING_CONFIGFILES +import x2go.inifiles as inifiles + +class X2goClientPrintingWINREG(inifiles.X2goIniFile): + """\ + L{X2goClientPrinting} provides access to the X2go ini-like file + »printing« as stored in C{~/.x2goclient/printing} resp. globally + C{/etc/x2goclient/printing}. + + An instance of L{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 = [] + _print_action = None + defaultValues = _X2GO_CLIENTPRINTING_DEFAULTS + + def __init__(self, config_files=_X2GO_PRINTING_CONFIGFILES, defaults=None, logger=None, loglevel=log.loglevel_DEFAULT): + """\ + @param config_files: a list of configuration files names (e.g. a global filename and a user's home + directory filename) + @type config_files: C{list} + @param defaults: a cascaded Python dicitionary structure with ini file defaults (to override + Python X2go's hard coded defaults in L{defaults} + @type defaults: C{dict} + @param logger: you can pass an L{X2goLogger} object to the + L{X2goPrintAction} constructor + @type logger: C{instance} + @param loglevel: if no L{X2goLogger} object has been supplied a new one will be + constructed with the given loglevel + @type loglevel: C{int} + + """ + inifiles.X2goIniFile.__init__(self, config_files, defaults=defaults, logger=logger, loglevel=loglevel) + + self._detect_print_action() + + + def _detect_print_action(self): + """\ + Derive a print action from sections, keys and their values in a typical + X2go client »printing« configuration file. + + """ + _general_pdfview = self.get('General', 'pdfview', key_type=types.BooleanType) + _view_open = self.get('view', 'open', key_type=types.BooleanType) + _print_startcmd = self.get('print', 'startcmd', key_type=types.BooleanType) + + if _general_pdfview and _view_open: + _view_command = self.get('view', 'command') + self._print_action = printing.X2goPrintActionPDFVIEW(pdfview_cmd=_view_command, logger=self.logger) + + elif _general_pdfview and not _view_open: + self._print_action = printing.X2goPrintActionPDFSAVE(logger=self.logger) + + elif not _general_pdfview and not _print_startcmd: + _cups_defaultprinter = self.get('CUPS', 'defaultprinter') + self._print_action = printing.X2goPrintActionPRINT(printer=_cups_defaultprinter, logger=self.logger) + + elif not _general_pdfview and _print_startcmd: + _print_command = self.get('print', 'command') + self._print_action = printing.X2goPrintActionPRINTCMD(print_cmd=_print_command, logger=self.logger) + + @property + def print_action(self): + """\ + Return the print action described by the »printing« configuration file. + + """ + return self._print_action + diff --git a/x2go/backends/profiles/__init__.py b/x2go/backends/profiles/__init__.py index 8eab147..0da4513 100644 --- a/x2go/backends/profiles/__init__.py +++ b/x2go/backends/profiles/__init__.py @@ -17,11 +17,12 @@ # Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. -from x2go.defaults import DEFAULT_SESSIONPROFILES_BACKEND +from x2go.defaults import BACKEND_SESSIONPROFILES_DEFAULT -from sessions_file import X2goSessionProfilesFILE -from win_registry import X2goSessionProfilesWINREG -from https_broker import X2goSessionProfilesHTTP +from _file import X2goSessionProfilesFILE +from _winreg import X2goSessionProfilesWINREG +from _httpsbroker import X2goSessionProfilesHTTPSBROKER +from _gconf import X2goSessionProfilesGCONF -X2goSessionProfiles = eval(DEFAULT_SESSIONPROFILES_BACKEND) +X2goSessionProfiles = eval(BACKEND_SESSIONPROFILES_DEFAULT) diff --git a/x2go/backends/profiles/sessions_file.py b/x2go/backends/profiles/_file.py similarity index 100% rename from x2go/backends/profiles/sessions_file.py rename to x2go/backends/profiles/_file.py diff --git a/x2go/backends/profiles/win_registry.py b/x2go/backends/profiles/_gconf.py similarity index 99% copy from x2go/backends/profiles/win_registry.py copy to x2go/backends/profiles/_gconf.py index 86f8fe7..1093717 100644 --- a/x2go/backends/profiles/win_registry.py +++ b/x2go/backends/profiles/_gconf.py @@ -38,7 +38,7 @@ import x2go.utils as hostname from x2go.x2go_exceptions import X2goProfileException -class X2goSessionProfilesWINREG(inifiles.X2goIniFile): +class X2goSessionProfilesGCONF(inifiles.X2goIniFile): defaultSessionProfile = X2GO_SESSIONPROFILE_DEFAULTS _non_profile_sections = ('embedded') diff --git a/x2go/backends/profiles/https_broker.py b/x2go/backends/profiles/_httpsbroker.py similarity index 99% rename from x2go/backends/profiles/https_broker.py rename to x2go/backends/profiles/_httpsbroker.py index 6fcc4b7..56b37b2 100644 --- a/x2go/backends/profiles/https_broker.py +++ b/x2go/backends/profiles/_httpsbroker.py @@ -37,7 +37,7 @@ import x2go.utils as utils from x2go.x2go_exceptions import X2goProfileException -class X2goSessionProfilesHTTP(inifiles.X2goIniFile): +class X2goSessionProfilesHTTPSBROKER(inifiles.X2goIniFile): defaultSessionProfile = X2GO_SESSIONPROFILE_DEFAULTS _non_profile_sections = ('embedded') diff --git a/x2go/backends/profiles/win_registry.py b/x2go/backends/profiles/_winreg.py similarity index 100% rename from x2go/backends/profiles/win_registry.py rename to x2go/backends/profiles/_winreg.py diff --git a/x2go/backends/proxy/__init__.py b/x2go/backends/proxy/__init__.py index 5ce688d..7371fa4 100644 --- a/x2go/backends/proxy/__init__.py +++ b/x2go/backends/proxy/__init__.py @@ -17,8 +17,8 @@ # Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. -from x2go.defaults import DEFAULT_PROXY_BACKEND +from x2go.defaults import BACKEND_PROXY_DEFAULT -from nx3 import X2goProxyNX3 +from _nx3 import X2goProxyNX3 -X2goProxy = eval(DEFAULT_PROXY_BACKEND) +X2goProxy = eval(BACKEND_PROXY_DEFAULT) diff --git a/x2go/backends/proxy/nx3.py b/x2go/backends/proxy/_nx3.py similarity index 100% rename from x2go/backends/proxy/nx3.py rename to x2go/backends/proxy/_nx3.py diff --git a/x2go/backends/profiles/__init__.py b/x2go/backends/settings/__init__.py similarity index 72% copy from x2go/backends/profiles/__init__.py copy to x2go/backends/settings/__init__.py index 8eab147..fd66188 100644 --- a/x2go/backends/profiles/__init__.py +++ b/x2go/backends/settings/__init__.py @@ -17,11 +17,12 @@ # Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. -from x2go.defaults import DEFAULT_SESSIONPROFILES_BACKEND +from x2go.defaults import BACKEND_CLIENTSETTINGS_DEFAULT -from sessions_file import X2goSessionProfilesFILE -from win_registry import X2goSessionProfilesWINREG -from https_broker import X2goSessionProfilesHTTP +from _file import X2goClientSettingsFILE +from _gconf import X2goClientSettingsGCONF +from _httpsbroker import X2goClientSettingsHTTPSBROKER +from _winreg import X2goClientSettingsWINREG -X2goSessionProfiles = eval(DEFAULT_SESSIONPROFILES_BACKEND) +X2goClientSettings = eval(BACKEND_CLIENTSETTINGS_DEFAULT) diff --git a/x2go/settings.py b/x2go/backends/settings/_file.py similarity index 82% copy from x2go/settings.py copy to x2go/backends/settings/_file.py index af3b3c4..4dc9b68 100644 --- a/x2go/settings.py +++ b/x2go/backends/settings/_file.py @@ -32,20 +32,20 @@ __NAME__ = 'x2gosettings-pylib' import os # Python X2go modules -import log -from defaults import X2GO_SETTINGS_CONFIGFILES -from defaults import X2GO_CLIENTSETTINGS_DEFAULTS -import inifiles +import x2go.log as log +from x2go.defaults import X2GO_SETTINGS_CONFIGFILES as _X2GO_SETTINGS_CONFIGFILES +from x2go.defaults import X2GO_CLIENTSETTINGS_DEFAULTS as _X2GO_CLIENTSETTINGS_DEFAULTS +import x2go.inifiles as inifiles -class X2goClientSettings(inifiles.X2goIniFile): +class X2goClientSettingsFILE(inifiles.X2goIniFile): """\ Configuration file based settings for X2goClient instances. """ - defaultValues = X2GO_CLIENTSETTINGS_DEFAULTS + defaultValues = _X2GO_CLIENTSETTINGS_DEFAULTS - def __init__(self, config_files=X2GO_SETTINGS_CONFIGFILES, defaults=None, logger=None, loglevel=log.loglevel_DEFAULT): + def __init__(self, config_files=_X2GO_SETTINGS_CONFIGFILES, defaults=None, logger=None, loglevel=log.loglevel_DEFAULT): """\ Constructs an L{X2goClientSettings} instance. This is normally done by an L{X2goClient} instance. You can retrieve this L{X2goClientSettings} instance with the L{X2goClient.get_client_settings()} diff --git a/x2go/settings.py b/x2go/backends/settings/_gconf.py similarity index 82% copy from x2go/settings.py copy to x2go/backends/settings/_gconf.py index af3b3c4..ab8442e 100644 --- a/x2go/settings.py +++ b/x2go/backends/settings/_gconf.py @@ -32,20 +32,20 @@ __NAME__ = 'x2gosettings-pylib' import os # Python X2go modules -import log -from defaults import X2GO_SETTINGS_CONFIGFILES -from defaults import X2GO_CLIENTSETTINGS_DEFAULTS -import inifiles +import x2go.log as log +from x2go.defaults import X2GO_SETTINGS_CONFIGFILES as _X2GO_SETTINGS_CONFIGFILES +from x2go.defaults import X2GO_CLIENTSETTINGS_DEFAULTS as _X2GO_CLIENTSETTINGS_DEFAULTS +import x2go.inifiles as inifiles -class X2goClientSettings(inifiles.X2goIniFile): +class X2goClientSettingsGCONF(inifiles.X2goIniFile): """\ Configuration file based settings for X2goClient instances. """ - defaultValues = X2GO_CLIENTSETTINGS_DEFAULTS + defaultValues = _X2GO_CLIENTSETTINGS_DEFAULTS - def __init__(self, config_files=X2GO_SETTINGS_CONFIGFILES, defaults=None, logger=None, loglevel=log.loglevel_DEFAULT): + def __init__(self, config_files=_X2GO_SETTINGS_CONFIGFILES, defaults=None, logger=None, loglevel=log.loglevel_DEFAULT): """\ Constructs an L{X2goClientSettings} instance. This is normally done by an L{X2goClient} instance. You can retrieve this L{X2goClientSettings} instance with the L{X2goClient.get_client_settings()} diff --git a/x2go/settings.py b/x2go/backends/settings/_httpsbroker.py similarity index 82% copy from x2go/settings.py copy to x2go/backends/settings/_httpsbroker.py index af3b3c4..e143529 100644 --- a/x2go/settings.py +++ b/x2go/backends/settings/_httpsbroker.py @@ -32,20 +32,20 @@ __NAME__ = 'x2gosettings-pylib' import os # Python X2go modules -import log -from defaults import X2GO_SETTINGS_CONFIGFILES -from defaults import X2GO_CLIENTSETTINGS_DEFAULTS -import inifiles +import x2go.log as log +from x2go.defaults import X2GO_SETTINGS_CONFIGFILES as _X2GO_SETTINGS_CONFIGFILES +from x2go.defaults import X2GO_CLIENTSETTINGS_DEFAULTS as _X2GO_CLIENTSETTINGS_DEFAULTS +import x2go.inifiles as inifiles -class X2goClientSettings(inifiles.X2goIniFile): +class X2goClientSettingsHTTPSBROKER(inifiles.X2goIniFile): """\ Configuration file based settings for X2goClient instances. """ - defaultValues = X2GO_CLIENTSETTINGS_DEFAULTS + defaultValues = _X2GO_CLIENTSETTINGS_DEFAULTS - def __init__(self, config_files=X2GO_SETTINGS_CONFIGFILES, defaults=None, logger=None, loglevel=log.loglevel_DEFAULT): + def __init__(self, config_files=_X2GO_SETTINGS_CONFIGFILES, defaults=None, logger=None, loglevel=log.loglevel_DEFAULT): """\ Constructs an L{X2goClientSettings} instance. This is normally done by an L{X2goClient} instance. You can retrieve this L{X2goClientSettings} instance with the L{X2goClient.get_client_settings()} diff --git a/x2go/settings.py b/x2go/backends/settings/_winreg.py similarity index 82% rename from x2go/settings.py rename to x2go/backends/settings/_winreg.py index af3b3c4..b8a6fef 100644 --- a/x2go/settings.py +++ b/x2go/backends/settings/_winreg.py @@ -32,20 +32,20 @@ __NAME__ = 'x2gosettings-pylib' import os # Python X2go modules -import log -from defaults import X2GO_SETTINGS_CONFIGFILES -from defaults import X2GO_CLIENTSETTINGS_DEFAULTS -import inifiles +import x2go.log as log +from x2go.defaults import X2GO_SETTINGS_CONFIGFILES as _X2GO_SETTINGS_CONFIGFILES +from x2go.defaults import X2GO_CLIENTSETTINGS_DEFAULTS as _X2GO_CLIENTSETTINGS_DEFAULTS +import x2go.inifiles as inifiles -class X2goClientSettings(inifiles.X2goIniFile): +class X2goClientSettingsWINREG(inifiles.X2goIniFile): """\ Configuration file based settings for X2goClient instances. """ - defaultValues = X2GO_CLIENTSETTINGS_DEFAULTS + defaultValues = _X2GO_CLIENTSETTINGS_DEFAULTS - def __init__(self, config_files=X2GO_SETTINGS_CONFIGFILES, defaults=None, logger=None, loglevel=log.loglevel_DEFAULT): + def __init__(self, config_files=_X2GO_SETTINGS_CONFIGFILES, defaults=None, logger=None, loglevel=log.loglevel_DEFAULT): """\ Constructs an L{X2goClientSettings} instance. This is normally done by an L{X2goClient} instance. You can retrieve this L{X2goClientSettings} instance with the L{X2goClient.get_client_settings()} diff --git a/x2go/backends/terminal/__init__.py b/x2go/backends/terminal/__init__.py index 91c158c..ff73773 100644 --- a/x2go/backends/terminal/__init__.py +++ b/x2go/backends/terminal/__init__.py @@ -17,8 +17,8 @@ # Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. -from x2go.defaults import DEFAULT_TERMINALSESSION_BACKEND +from x2go.defaults import BACKEND_TERMINALSESSION_DEFAULT -from stdout import X2goTerminalSessionSTDOUT +from _stdout import X2goTerminalSessionSTDOUT -X2goTerminalSession = eval(DEFAULT_TERMINALSESSION_BACKEND) +X2goTerminalSession = eval(BACKEND_TERMINALSESSION_DEFAULT) diff --git a/x2go/backends/terminal/stdout.py b/x2go/backends/terminal/_stdout.py similarity index 100% rename from x2go/backends/terminal/stdout.py rename to x2go/backends/terminal/_stdout.py diff --git a/x2go/client.py b/x2go/client.py index 07a2938..de19c04 100644 --- a/x2go/client.py +++ b/x2go/client.py @@ -124,8 +124,6 @@ import types import os # Python X2go modules -from settings import X2goClientSettings -from printing import X2goClientPrinting from registry import X2goSessionRegistry from guardian import X2goSessionGuardian from cache import X2goListSessionsCache @@ -139,7 +137,14 @@ from defaults import LOCAL_HOME as _LOCAL_HOME from defaults import CURRENT_LOCAL_USER as _CURRENT_LOCAL_USER from defaults import X2GO_CLIENT_ROOTDIR as _X2GO_CLIENT_ROOTDIR -from x2go.backends.profiles import X2goSessionProfiles +from x2go.backends.control import X2goControlSession as _X2goControlSession +from x2go.backends.terminal import X2goTerminalSession as _X2goTerminalSession +from x2go.backends.info import X2goServerSessionInfo as _X2goServerSessionInfo +from x2go.backends.info import X2goServerSessionList as _X2goServerSessionList +from x2go.backends.proxy import X2goProxy as _X2goProxy +from x2go.backends.profiles import X2goSessionProfiles as _X2goSessionProfiles +from x2go.backends.settings import X2goClientSettings as _X2goClientSettings +from x2go.backends.printing import X2goClientPrinting as _X2goClientPrinting if _X2GOCLIENT_OS == 'Windows': from xserver import X2goClientXConfig, X2goXServer @@ -155,7 +160,16 @@ class X2goClient(object): session object etc.) and connected to it (authentication). For these two steps use these methods: L{X2goClient.register_session()} and L{X2goClient.connect_session()}. """ - def __init__(self, use_cache=True, start_xserver=False, logger=None, loglevel=log.loglevel_DEFAULT): + def __init__(self, use_cache=True, start_xserver=False, + control_backend=_X2goControlSession, + terminal_backend=_X2goTerminalSession, + info_backend=_X2goServerSessionInfo, + list_backend=_X2goServerSessionList, + proxy_backend=_X2goProxy, + profiles_backend=_X2goSessionProfiles, + settings_backend=_X2goClientSettings, + printing_backend=_X2goClientPrinting, + logger=None, loglevel=log.loglevel_DEFAULT): """\ @param logger: you can pass an L{X2goLogger} object to the L{X2goClient} constructor @@ -175,6 +189,12 @@ class X2goClient(object): if self.logger.tag is None: self.logger.tag = self._logger_tag + self.control_backend = control_backend + self.terminal_backend = terminal_backend + self.info_backend = info_backend + self.list_backend = list_backend + self.proxy_backend = proxy_backend + if _X2GOCLIENT_OS == 'Windows' and start_xserver: self.client_xconfig = X2goClientXConfig(logger=self.logger) if not self.client_xconfig.running_xservers: @@ -187,14 +207,16 @@ class X2goClient(object): else: # presume the running XServer listens on :0 os.environ.update({'DISPLAY': 'localhost:0'}) - - self.session_profiles = X2goSessionProfiles(logger=self.logger) - self.session_registry = X2goSessionRegistry(logger=self.logger) + + self.session_profiles = profiles_backend(logger=self.logger) + self.session_registry = X2goSessionRegistry( + logger=self.logger, + ) self.session_guardian = X2goSessionGuardian(self, enable_cache=use_cache, logger=self.logger) if use_cache: self.listsessions_cache = X2goListSessionsCache(self, logger=self.logger) - self.client_settings = X2goClientSettings(logger=self.logger) - self.client_printing = X2goClientPrinting(logger=self.logger) + self.client_settings = settings_backend(logger=self.logger) + self.client_printing = printing_backend(logger=self.logger) self.use_cache = use_cache @@ -339,10 +361,14 @@ class X2goClient(object): _params['printing'] = printing _params['share_local_folders'] = share_local_folders - session_uuid = self.session_registry.register(server=server, profile_id=_profile_id, profile_name=_profile_name, **_params ) - - control_params = self.session_registry(session_uuid).control_params - terminal_params = self.session_registry(session_uuid).terminal_params + session_uuid = self.session_registry.register(server=server, + profile_id=_profile_id, profile_name=_profile_name, + control_backend=self.control_backend, + terminal_backend=self.terminal_backend, + info_backend=self.info_backend, + list_backend=self.list_backend, + proxy_backend=self.proxy_backend, + **_params ) self.logger('initializing X2go session...', log.loglevel_NOTICE, tag=self._logger_tag) if return_object: diff --git a/x2go/defaults.py b/x2go/defaults.py index 6712d75..b7df25d 100644 --- a/x2go/defaults.py +++ b/x2go/defaults.py @@ -70,21 +70,57 @@ else: ## -## control and terminal session backend as well as session info backend defaults +## control and terminal session backend as well as session info and proxy backend defaults ## -DEFAULT_CONTROLSESSION_BACKEND = 'X2goControlSessionSTDOUT' -DEFAULT_TERMINALSESSION_BACKEND = 'X2goTerminalSessionSTDOUT' -DEFAULT_SERVERSESSIONINFO_BACKEND = 'X2goServerSessionInfoSTDOUT' -DEFAULT_SERVERSESSIONLIST_BACKEND = 'X2goServerSessionListSTDOUT' -DEFAULT_PROXY_BACKEND = 'X2goProxyNX3' +BACKENDS_CONTROLSESSION = { + 'STDOUT': 'X2goControlSessionSTDOUT', +} +BACKENDS_TERMINALSESSION = { + 'STDOUT': 'X2goTerminalSessionSTDOUT', +} +BACKENDS_SERVERSESSIONINFO = { + 'STDOUT': 'X2goServerSessionInfoSTDOUT', +} +BACKENDS_SERVERSESSIONLIST = { + 'STDOUT': 'X2goServerSessionListSTDOUT', +} +BACKENDS_PROXY = { + 'NX3': 'X2goProxyNX3', +} + +BACKEND_CONTROLSESSION_DEFAULT = 'X2goControlSessionSTDOUT' +BACKEND_TERMINALSESSION_DEFAULT = 'X2goTerminalSessionSTDOUT' +BACKEND_SERVERSESSIONINFO_DEFAULT = 'X2goServerSessionInfoSTDOUT' +BACKEND_SERVERSESSIONLIST_DEFAULT = 'X2goServerSessionListSTDOUT' +BACKEND_PROXY_DEFAULT = 'X2goProxyNX3' ## ## profile backend defaults ## -DEFAULT_SESSIONPROFILES_BACKEND = 'X2goSessionProfilesFILE' +BACKENDS_SESSIONPROFILES = { + 'FILE': 'X2goSessionProfilesFILE', + 'GCONF': 'X2goSessionProfilesGCONF', + 'HTTPSBROKER': 'X2goSessionProfilesHTTPSBROKER', + 'WINREG': 'X2goSessionProfilesWINREG', +} +BACKENDS_CLIENTSETTINGS = { + 'FILE': 'X2goClientSettingsFILE', + 'GCONF': 'X2goClientSettingsGCONF', + 'HTTPSBROKER': 'X2goClientSettingsHTTPSBROKER', + 'WINREG': 'X2goClientSettingsWINREG', +} +BACKENDS_CLIENTPRINTING = { + 'FILE': 'X2goClientPrintingFILE', + 'GCONF': 'X2goClientPrintingGCONF', + 'HTTPSBROKER': 'X2goClientPrintingHTTPSBROKER', + 'WINREG': 'X2goClientPrintingWINREG', +} +BACKEND_SESSIONPROFILES_DEFAULT = 'X2goSessionProfilesFILE' +BACKEND_CLIENTSETTINGS_DEFAULT = 'X2goClientSettingsFILE' +BACKEND_CLIENTPRINTING_DEFAULT = 'X2goClientPrintingFILE' ## ## X2go Printing diff --git a/x2go/registry.py b/x2go/registry.py index 95f25e3..619cf56 100644 --- a/x2go/registry.py +++ b/x2go/registry.py @@ -35,18 +35,19 @@ import session from x2go_exceptions import * # import the default terminal session backend -from x2go.backends.control import X2goControlSession -from x2go.backends.terminal import X2goTerminalSession -from x2go.backends.proxy import X2goProxy -from x2go.backends.info import X2goServerSessionInfo -from x2go.backends.info import X2goServerSessionList +from x2go.backends.control import X2goControlSession as _X2goControlSession +from x2go.backends.terminal import X2goTerminalSession as _X2goTerminalSession +from x2go.backends.info import X2goServerSessionInfo as _X2goServerSessionInfo +from x2go.backends.info import X2goServerSessionList as _X2goServerSessionList +from x2go.backends.proxy import X2goProxy as _X2goProxy class X2goSessionRegistry(object): """\ STILL UNDOCUMENTED """ - def __init__(self, use_cache=True, logger=None, loglevel=log.loglevel_DEFAULT): + def __init__(self, use_cache=True, + logger=None, loglevel=log.loglevel_DEFAULT): """\ STILL UNDOCUMENTED @@ -117,11 +118,11 @@ class X2goSessionRegistry(object): return _session_summary def register(self, server, profile_id, profile_name, - control_backend=X2goControlSession, - terminal_backend=X2goTerminalSession, - info_backend=X2goServerSessionInfo, - list_backend=X2goServerSessionList, - proxy_backend=X2goProxy, + control_backend=_X2goControlSession, + terminal_backend=_X2goTerminalSession, + info_backend=_X2goServerSessionInfo, + list_backend=_X2goServerSessionList, + proxy_backend=_X2goProxy, **kwargs): control_session = None hooks/post-receive -- python-x2go.git (Python X2Go Client API) This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "python-x2go.git" (Python X2Go Client API).