This is an automated email from the git hooks/post-receive script. x2go pushed a change to branch brokerclient in repository python-x2go. from 9fc8c3e fix _get_profile_parameter() in profile backend's base.py file new 3088eda some code beautifications new 86d185a Default to xdg-open as default PDF viewer command. new 8014735 Provide basic session profile backend for a http broker. The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: debian/changelog | 2 + x2go/backends/profiles/base.py | 2 + x2go/backends/profiles/httpbroker.py | 83 ++++++++++++++++++++++++++++------ x2go/client.py | 10 +++- x2go/defaults.py | 2 +- x2go/printactions.py | 4 +- 6 files changed, 84 insertions(+), 19 deletions(-) -- Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/python-x2go.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch brokerclient in repository python-x2go. commit 86d185a570ec517515da47852f401633c9004f51 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Tue Mar 4 13:57:43 2014 +0100 Default to xdg-open as default PDF viewer command. --- debian/changelog | 1 + x2go/defaults.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 5a9604d..0c28057 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,7 @@ python-x2go (0.5.0.0-0x2go1) UNRELEASED; urgency=low with earlier versions of Python X2Go concerning backends (probably not really used by third-party products, if at all). - Fix setting default values in X2GoClientXConfig class. + - Default to xdg-open as default PDF viewer command. -- Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Sun, 05 Jan 2014 16:35:57 +0100 diff --git a/x2go/defaults.py b/x2go/defaults.py index 4cea579..59373f4 100644 --- a/x2go/defaults.py +++ b/x2go/defaults.py @@ -217,7 +217,7 @@ X2GO_CLIENTPRINTING_DEFAULTS = { # if open is false, the incoming print job is saved in ~/PDF folder 'open': True, # command to execute as PDF viewer - 'command': 'xpdf', + 'command': 'xdg-open', }, 'CUPS': { # default print queue for CUPS, if print queue does not exist, the default -- Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/python-x2go.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch brokerclient in repository python-x2go. commit 3088eda9bf1494527afecc4b36c56a8caff314d0 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Tue Mar 4 13:56:49 2014 +0100 some code beautifications --- x2go/printactions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x2go/printactions.py b/x2go/printactions.py index 9698a85..18dc185 100644 --- a/x2go/printactions.py +++ b/x2go/printactions.py @@ -205,7 +205,7 @@ class X2GoPrintActionPDFVIEW(X2GoPrintAction): spool_dir = os.path.normpath(spool_dir) if _X2GOCLIENT_OS == "Windows": - self.logger('viewing incoming job in PDF viewer with Python\'s os.startfile( command): %s' % pdf_file, loglevel=log.loglevel_DEBUG) + self.logger('viewing incoming job in PDF viewer with Python\'s os.startfile(command): %s' % pdf_file, loglevel=log.loglevel_DEBUG) try: gevent.spawn(os.startfile, pdf_file) except WindowsError, win_err: @@ -320,7 +320,7 @@ class X2GoPrintActionPRINT(X2GoPrintAction): def _do_print(self, pdf_file, job_title, spool_dir, ): """\ - Actually really print an incoming X2Go print job (PDF file) to a local printer device. + Really print an incoming X2Go print job (PDF file) to a local printer device. @param pdf_file: PDF file name as placed in to the X2Go spool directory @type pdf_file: C{str} -- Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/python-x2go.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch brokerclient in repository python-x2go. commit 8014735e439c4f6a4d3c71e532d6e8d525103f27 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Tue Mar 4 13:58:21 2014 +0100 Provide basic session profile backend for a http broker. --- debian/changelog | 1 + x2go/backends/profiles/base.py | 2 + x2go/backends/profiles/httpbroker.py | 83 ++++++++++++++++++++++++++++------ x2go/client.py | 10 +++- 4 files changed, 80 insertions(+), 16 deletions(-) diff --git a/debian/changelog b/debian/changelog index 0c28057..3d245b2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,7 @@ python-x2go (0.5.0.0-0x2go1) UNRELEASED; urgency=low not really used by third-party products, if at all). - Fix setting default values in X2GoClientXConfig class. - Default to xdg-open as default PDF viewer command. + - Provide basic session profile backend for a http broker. -- Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Sun, 05 Jan 2014 16:35:57 +0100 diff --git a/x2go/backends/profiles/base.py b/x2go/backends/profiles/base.py index 6985f9a..7660165 100644 --- a/x2go/backends/profiles/base.py +++ b/x2go/backends/profiles/base.py @@ -64,6 +64,8 @@ class X2GoSessionProfiles(): self._cached_profile_names = [] self._profiles_need_profile_id_renewal = [] self.write_user_config = False + self.config_files = None + self.user_config_file = None if logger is None: self.logger = log.X2GoLogger(loglevel=loglevel) diff --git a/x2go/backends/profiles/httpbroker.py b/x2go/backends/profiles/httpbroker.py index 0d27cb4..1739597 100644 --- a/x2go/backends/profiles/httpbroker.py +++ b/x2go/backends/profiles/httpbroker.py @@ -26,8 +26,15 @@ applications. """ __NAME__ = 'x2gosessionprofiles-pylib' +import copy +import re +import requests +try: import simplejson as json +except ImportError: import json + # Python X2Go modules -from x2go.defaults import X2GO_SESSIONPROFILE_DEFAULTS +from x2go.defaults import X2GO_SESSIONPROFILE_DEFAULTS as _X2GO_SESSIONPROFILE_DEFAULTS +from x2go.defaults import CURRENT_LOCAL_USER as _CURRENT_LOCAL_USER import x2go.backends.profiles.base as base import x2go.log as log @@ -35,14 +42,21 @@ from x2go.x2go_exceptions import X2GoNotImplementedYetException class X2GoSessionProfiles(base.X2GoSessionProfiles): - defaultSessionProfile = X2GO_SESSIONPROFILE_DEFAULTS + defaultSessionProfile = _X2GO_SESSIONPROFILE_DEFAULTS - def __init__(self, session_profile_defaults=None, logger=None, loglevel=log.loglevel_DEFAULT): + def __init__(self, session_profile_defaults=None, + broker_url="http://localhost:8080/json/", + broker_user=None, + broker_password=None, + logger=None, loglevel=log.loglevel_DEFAULT, + **kwargs): """\ Retrieve X2Go session profiles from a HTTP(S) session broker. @param session_profile_defaults: a default session profile @type session_profile_defaults: C{dict} + @param broker_url: URL for accessing the X2Go Session Broker + @type broker_url: C{str} @param logger: you can pass an L{X2GoLogger} object to the L{X2GoSessionProfilesHTTPSBROKER} constructor @type logger: L{X2GoLogger} instance @@ -51,8 +65,48 @@ class X2GoSessionProfiles(base.X2GoSessionProfiles): @type loglevel: C{int} """ + match = re.match('^(?P<protocol>(http(|s)))://(|(?P<user>[a-zA-Z0-9_\.-]+)(|:(?P<password>.*))@)(?P<hostname>[a-zA-Z0-9\.-]+)(|:(?P<port>[0-9]+))($|/(?P<path>.*)$)', broker_url) + p = match.groupdict() + if p['user']: + self.broker_user = p['user'] + else: + self.broker_user = broker_user + if p['password']: + self.broker_password = p['password'] + else: + self.broker_password = broker_password + + # fine-tune the URL + p['path'] = "/{path}".format(**p) + if p['port'] is not None: + p['port'] = ":{port}".format(**p) + + self.broker_url = "{protocol}://{hostname}{port}{path}".format(**p) + base.X2GoSessionProfiles.__init__(self, session_profile_defaults=session_profile_defaults, logger=logger, loglevel=loglevel) + def broker_simpleauth(self, broker_user, broker_password): + payload = { + 'user': broker_user, + 'password': broker_password, + } + r = requests.post(self.broker_url, data=payload) + if r.status_code == 200: + self.broker_user = broker_user + self.broker_password = broker_password + return True + return False + + def broker_listsessions(self): + payload = { + 'task': 'listsessions', + 'user': self.broker_user, + 'password': self.broker_password, + } + r = requests.post(self.broker_url, data=payload) + if r.status_code == 200 and r.headers['content-type'].startswith("text/json"): + return json.loads(r.text) + def _populate_session_profiles(self): """\ Populate the set of session profiles by loading the session @@ -62,31 +116,30 @@ class X2GoSessionProfiles(base.X2GoSessionProfiles): @rtype: C{dict} """ - session_profiles = LOAD + session_profiles = self.broker_listsessions() + _session_profiles = copy.deepcopy(session_profiles) - for session_profile in session_profiles: + for session_profile in _session_profiles: for key, default_value in self.defaultSessionProfile.iteritems(): - if not self.iniConfig.has_option(session_profile, key): - self._storeValue(session_profile, key, default_value) - # update cached meta type session profile information - self.get_profile_metatype(session_profile) + if not session_profiles[session_profile].has_key(key): + session_profiles[session_profile][key] = default_value return session_profiles def _write(self): - print "BROKER CLIENT: WRITING SESSION PROFILES IS NOT SUPPORTED" + print "not suported" def _delete_profile(self, profile_id): - print "BROKER CLIENT: DELETING SESSION PROFILES IS NOT SUPPORTED" + del self.session_profiles[profile_id] def _update_value(self, profile_id, option, value): - print "BROKER CLIENT: MODIFYING SESSION PROFILES IS NOT SUPPORTED" + self.session_profiles[profile_id][option] = value def _get_profile_parameter(self, profile_id, option, key_type): - print "TODO" + return key_type(self.session_profiles[profile_id][option]) def _get_profile_options(self, profile_id): - print "TODO" + return self.session_profiles[profile_id].keys() def _get_profile_ids(self): - print "TODO" + return self.session_profiles.keys() diff --git a/x2go/client.py b/x2go/client.py index debba28..b0bace6 100644 --- a/x2go/client.py +++ b/x2go/client.py @@ -182,6 +182,7 @@ class X2GoClient(object): profiles_backend=_BACKENDS['X2GoSessionProfiles']['default'], settings_backend=_BACKENDS['X2GoClientSettings']['default'], printing_backend=_BACKENDS['X2GoClientPrinting']['default'], + broker_url=None, client_rootdir=None, sessions_rootdir=None, ssh_rootdir=None, @@ -268,6 +269,13 @@ class X2GoClient(object): self.info_backend = utils._get_backend_class(info_backend, "X2GoServerSessionInfo") self.list_backend = utils._get_backend_class(list_backend, "X2GoServerSessionList") self.proxy_backend = utils._get_backend_class(proxy_backend, "X2GoProxy") + print broker_url + if broker_url is not None: + if broker_url.startswith('ssh://'): + profiles_backend = 'sshbroker' + elif broker_url.startswith('http://') or broker_url.startswith('https://'): + self.logger('using http(s) broker at URL %s' % broker_url, loglevel=log.loglevel_NOTICE) + profiles_backend = 'httpbroker' self.profiles_backend = utils._get_backend_class(profiles_backend, "X2GoSessionProfiles") self.settings_backend = utils._get_backend_class(settings_backend, "X2GoClientSettings") self.printing_backend = utils._get_backend_class(printing_backend, "X2GoClientPrinting") @@ -288,7 +296,7 @@ class X2GoClient(object): _settings_config_file = os.path.join(self.client_rootdir, _X2GO_SETTINGS_FILENAME) _printing_config_file = os.path.join(self.client_rootdir, _X2GO_PRINTING_FILENAME) _xconfig_config_file = os.path.join(self.client_rootdir, _X2GO_XCONFIG_FILENAME) - self.session_profiles = self.profiles_backend(config_files=[_sessions_config_file], logger=self.logger) + self.session_profiles = self.profiles_backend(config_files=[_sessions_config_file], logger=self.logger, broker_url=broker_url) self.client_settings = self.settings_backend(config_files=[_settings_config_file], logger=self.logger) self.client_printing = self.printing_backend(config_files=[_printing_config_file], client_instance=self, logger=self.logger) else: -- Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/python-x2go.git