[X2go-Commits] python-x2go.git - master (branch) updated: 0.1.1.4-164-g521d91d
X2Go dev team
git-admin at x2go.org
Mon Mar 26 17:50:45 CEST 2012
The branch, master has been updated
via 521d91dfd683e3221ba0d37d24c5419f4dfb4852 (commit)
via 41e9e07ffcd534af310b1a7dd48c04d9fbd72356 (commit)
from 5337f67d11bd2b5c7d2d394495a55d533d0c4c53 (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 -----------------------------------------------------------------
commit 521d91dfd683e3221ba0d37d24c5419f4dfb4852
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date: Mon Mar 26 17:47:18 2012 +0200
Provide X2goClient method get_session_info(), do not auto start/resume sessions in published applications mode, provide hook method for auto-connecting interactively.
commit 41e9e07ffcd534af310b1a7dd48c04d9fbd72356
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date: Mon Mar 26 17:50:17 2012 +0200
Docstring fix, add X2goClient method is_session_profile(), return registered session for a specific session name if it has already been registered instead of registering a new session.
-----------------------------------------------------------------------
Summary of changes:
debian/changelog | 6 +++++
x2go/backends/terminal/_stdout.py | 7 +++++
x2go/client.py | 45 ++++++++++++++++++++++++++++++++++++-
x2go/session.py | 41 +++++++++++++++++++++++++++++++--
4 files changed, 95 insertions(+), 4 deletions(-)
The diff of changes is:
diff --git a/debian/changelog b/debian/changelog
index ddca0e5..785a616 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -69,6 +69,12 @@ python-x2go (0.1.2.0-0~x2go1) UNRELEASED; urgency=low
default known_xservers with configured known_xservers.
- Make sure xconfig configuration changes provided by defaults.py get
written to the config file.
+ - Docstring fix, add X2goClient method is_session_profile(), return registered
+ session for a specific session name if it has already been registered instead
+ of registering a new session.
+ - Provide X2goClient method get_session_info(), do not auto start/resume sessions
+ in published applications mode, provide hook method for auto-connecting
+ interactively.
* Depend on python-xlib.
-- Mike Gabriel <mike.gabriel at das-netzwerkteam.de> Sat, 28 Sep 2012 01:44:21 +0100
diff --git a/x2go/backends/terminal/_stdout.py b/x2go/backends/terminal/_stdout.py
index 32798af..6cfbac1 100644
--- a/x2go/backends/terminal/_stdout.py
+++ b/x2go/backends/terminal/_stdout.py
@@ -393,6 +393,13 @@ class X2goTerminalSessionSTDOUT(object):
"""
return self.session_info.name
+ def get_session_info(self):
+ """\
+ STILL UNDOCUMENTED
+
+ """
+ return self.session_info
+
def get_session_cmd(self):
"""\
STILL UNDOCUMENTED
diff --git a/x2go/client.py b/x2go/client.py
index de17a43..ef04361 100644
--- a/x2go/client.py
+++ b/x2go/client.py
@@ -331,6 +331,13 @@ class X2goClient(object):
self.auto_update_listdesktops_cache = auto_update_listdesktops_cache
self.auto_update_listmounts_cache = auto_update_listmounts_cache
+ def HOOK_profile_auto_connect(self, profile_name='UNKNOWN'):
+ """\
+ HOOK method: called if a session demands to auto connect the session profile.
+
+ """
+ self.logger('HOOK_profile_auto_connect: profile ,,%s'' wants to be auto-connected to the X2Go server.' % profile_name, loglevel=log.loglevel_WARN)
+
def HOOK_session_startup_failed(self, profile_name='UNKNOWN'):
"""\
HOOK method: called if the startup of a session failed.
@@ -879,6 +886,13 @@ class X2goClient(object):
@rtype: C{str}
"""
+
+ # test if session_name has already been registered. If yes, return it immediately.
+ if type(session_name) is types.StringType:
+ _retval = self.get_session_of_session_name(session_name, return_object=return_object)
+ if _retval is not None:
+ return _retval
+
if known_hosts is None:
known_hosts = os.path.join(_LOCAL_HOME, self.ssh_rootdir, 'known_hosts')
@@ -1064,6 +1078,21 @@ class X2goClient(object):
return self.session_registry(session_uuid).get_session_name()
__get_session_name = get_session_name
+ def get_session_info(self, session_uuid):
+ """\
+ Retrieve the server-side X2Go session information object for the session that has
+ been registered under C{session_uuid}.
+
+ @param session_uuid: the X2Go session's UUID registry hash
+ @type session_uuid: C{str}
+
+ @return: X2Go session info
+ @rtype: C{obj}
+
+ """
+ return self.session_registry(session_uuid).get_session_info()
+ __get_session_info = get_session_info
+
def set_session_username(self, session_uuid, username):
"""\
Set the session username for the L{X2goSession} that has been registered under C{session_uuid}.
@@ -1561,7 +1590,7 @@ class X2goClient(object):
Test if the X2Go given session profile has open connections
to the X2Go server.
- @param profile_name: the X2Go session's UUID registry hash
+ @param profile_name: a valid session profile name
@type profile_name: C{str}
@return: C{True} if profile has a connected session, C{False} otherwise
@@ -1571,6 +1600,20 @@ class X2goClient(object):
return bool(self.client_connected_sessions_of_profile_name(profile_name=profile_name))
__is_profile_connected = is_profile_connected
+ def is_session_profile(self, profile_id_or_name):
+ """\
+ Test if the X2Go given session profile is configured in the client's C{sessions} file.
+
+ @param profile_id_or_name: test existence of this session profile name (or id)
+ @type profile_id_or_name: C{str}
+
+ @return: C{True} if session profile exists, C{False} otherwise
+ @rtype: C{bool}
+
+ """
+ return self.session_profiles.has_profile(profile_id_or_name)
+ __is_session_profile = is_session_profile
+
def is_session_running(self, session_uuid, session_name=None):
"""\
Test if the X2Go session registered as C{session_uuid} is up
diff --git a/x2go/session.py b/x2go/session.py
index 1bbea20..8ec10f0 100644
--- a/x2go/session.py
+++ b/x2go/session.py
@@ -308,6 +308,16 @@ class X2goSession(object):
if self.is_connected():
self.retrieve_server_features()
+ def HOOK_auto_connect(self):
+ """\
+ HOOK method: called if the session demands to auto connect.
+
+ """
+ if self.client_instance:
+ self.client_instance.HOOK_profile_auto_connect(profile_name=self.profile_name)
+ else:
+ self.logger('HOOK_auto_connect: profile ,,%s'' wants to auto-connect to the X2Go server.' % self.profile_name, loglevel=log.loglevel_WARN)
+
def HOOK_session_startup_failed(self):
"""\
HOOK method: called if the startup of a session failed.
@@ -716,6 +726,18 @@ class X2goSession(object):
return self.session_name
__get_session_name = get_session_name
+ def get_session_info(self):
+ """\
+ Retrieve the server-side X2Go session info object for this session.
+
+ @return: X2Go session info
+ @rtype: C{obj}
+
+ """
+ if self.has_terminal_session():
+ self.terminal_session.get_session_info()
+ __get_session_info = get_session_info
+
def get_session_cmd(self):
"""\
Retrieve the server-side command that is used to start a session
@@ -890,6 +912,8 @@ class X2goSession(object):
else:
if self.can_auto_connect() and self.auto_connect:
gevent.spawn(self.connect)
+ else:
+ gevent.spawn(self.HOOK_auto_connect)
def connect(self, username='', password='', add_to_known_hosts=False, force_password_auth=False,
use_sshproxy=False, sshproxy_user='', sshproxy_password=''):
@@ -1296,7 +1320,11 @@ class X2goSession(object):
def do_auto_start_or_resume(self, newest=True, oldest=False, all_suspended=False, start=True, redirect_to_client=True):
"""\
- Automatically start or resume this session.
+ Automatically start or resume this session, if already associated with a server session. Otherwise
+ resume a server-side available/suspended session (see options to declare which session to resume).
+ If no session is available for resuming a new session will be launched.
+
+ Sessions in published applications mode are not resumed/started by this method.
@param newest: if resuming, only resume newest/youngest session
@type newest: C{bool}
@@ -1314,10 +1342,16 @@ class X2goSession(object):
if self.client_instance and redirect_to_client:
return self.client_instance.session_auto_start_or_resume(self())
else:
- if self.session_name is not None:
+ if self.session_name is not None and 'PUBLISHED' not in self.session_name:
return self.resume()
else:
session_infos = self.list_sessions()
+
+ # only auto start/resume non-pubapp sessions
+ for session_name in session_infos.keys():
+ if session_infos[session_name].is_published_applications_provider():
+ del session_infos[session_name]
+
if session_infos:
if newest:
return self.resume(session_name=utils.session_names_by_timestamp(session_infos)[-1])
@@ -1327,7 +1361,8 @@ class X2goSession(object):
for session_name in [ _sn for _sn in session_infos.keys() if session_infos[_sn].is_suspended() ]:
return self.resume(session_name=session_name)
else:
- return self.start()
+ if not self.published_applications:
+ return self.start()
def resume(self, session_name=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).
More information about the x2go-commits
mailing list