The branch, twofactorauth has been updated via 134506d0adc29c0ee85a716c3f2181f9788253b2 (commit) from efa7e704ac2aea6b04d290015e074ea5d1b3e8a5 (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: x2go/client.py | 134 ++++++++++++++++++++++++++++++++++++++++++++---------- x2go/registry.py | 21 +++++++-- x2go/session.py | 7 +++ 3 files changed, 133 insertions(+), 29 deletions(-) The diff of changes is: diff --git a/x2go/client.py b/x2go/client.py index 9ee2aef..0de8d33 100644 --- a/x2go/client.py +++ b/x2go/client.py @@ -433,6 +433,16 @@ class X2goClient(object): ) __connect_session = connect_session + def disconnect_session(self, session_uuid): + """\ + Disconnect an L{X2goSession} by closing down its Paramiko/SSH Transport thread. + + @param session_uuid: the X2go session's UUID registry hash + @type session_uuid: C{str} + """ + self.session_registry(session_uuid).disconnect() + __disconnect_session = disconnect_session + def set_session_print_action(self, session_uuid, print_action, **kwargs): """\ If X2go client-side printing is enable within an X2go session you can use @@ -532,13 +542,13 @@ class X2goClient(object): @rtype: C{bool} """ - if session_name: - # suspend a non-registered session by session name - session = self.session_registry(session_uuid).session_object - session.associate(session_name) - return session.suspend(session_name=session_name) + if session_name is None: + return self.session_registry(session_uuid).suspend(session_name=session_name) else: - return self.session_registry(session_uuid).suspend() + for session in self.session_registry.running_sessions: + if session_name == session.get_session_name(): + return session.suspend() + return self.session_registry(session_uuid).session_object.suspend(session_name=session_name) __suspend_session = suspend_session def terminate_session(self, session_uuid, session_name=None): @@ -571,13 +581,13 @@ class X2goClient(object): @rtype: C{bool} """ - if session_name: - # terminate a non-registered session by session name - session = self.session_registry(session_uuid).session_object - session.associate(session_name) - return session.terminate(session_name=session_name) + if session_name is None: + return self.session_registry(session_uuid).terminate(session_name=session_name) else: - return self.session_registry(session_uuid).terminate() + for session in self.session_registry.running_sessions + self.session_registry.suspended_sessions: + if session_name == session.get_session_name(): + return session.terminate() + return self.session_registry(session_uuid).session_object.terminate(session_name=session_name) __terminate_session = terminate_session def get_session_profile_name(self, session_uuid): @@ -667,7 +677,7 @@ class X2goClient(object): @rtype: C{bool} """ - return self.session_registry(session_uuid).is_running() + return self.session_registry(session_uuid).is_running(session_name=session_name) __is_session_running = is_session_running def is_session_suspended(self, session_uuid): @@ -682,7 +692,7 @@ class X2goClient(object): @rtype: C{bool} """ - return self.session_registry(session_uuid).is_suspended() + return self.session_registry(session_uuid).is_suspended(session_name=session_name) __is_session_suspended = is_session_suspended def has_session_terminated(self, session_uuid): @@ -722,10 +732,10 @@ class X2goClient(object): __share_local_folder_with_session = share_local_folder_with_session ### - ### Provide access to the session registry + ### Provide access to the X2goClient's session registry ### - def connected_sessions(self, return_objects=False, return_profile_names=False): + def client_connected_sessions(self, return_objects=False, return_profile_names=False): """\ STILL UNDOCUMENTED @@ -734,18 +744,29 @@ class X2goClient(object): return [ obj for obj in self.session_registry.connected_sessions ] if return_profile_names: return [ obj.get_profile_name() for obj in self.session_registry.connected_sessions ] - return [ obj.get_uuid() for obj in self.session_registry.connected_sessions ] - __connected_sessions = connected_sessions + return [ obj() for obj in self.session_registry.connected_sessions ] + __client_connected_sessions = client_connected_sessions + + def client_connected_sessions_of_name(self, profile_name, return_objects=False): + """\ + STILL UNDOCUMENTED + + """ + if return_objects: + return [ obj for obj in self.session_registry.connected_sessions if self.session_registry.profile_name == profile_name ] + return [ obj() for obj in self.session_registry.connected_sessions if self.session_registry.profile_name == profile_name ] + __client_connected_sessions = client_connected_sessions @property - def has_connected_sessions(self): + def client_has_connected_sessions(self): """\ STILL UNDOCUMENTED """ return self.session_registry.has_connected_sessions + __client_has_connected_sessions = client_has_connected_sessions - def running_sessions(self, return_objects=False, return_profile_names=False): + def client_running_sessions(self, return_objects=False, return_profile_names=False): """\ STILL UNDOCUMENTED @@ -755,17 +776,18 @@ class X2goClient(object): if return_profile_names: return [ obj.get_profile_name() for obj in self.session_registry.running_sessions ] return [ obj.get_uuid() for obj in self.session_registry.running_sessions ] - __running_sessions = running_sessions + __client_running_sessions = client_running_sessions @property - def has_running_sessions(self): + def client_has_running_sessions(self): """\ STILL UNDOCUMENTED """ return self.session_registry.has_running_sessions + __client_has_running_sessions = client_has_running_sessions - def suspended_sessions(self, return_objects=False, return_profile_names=False): + def client_suspended_sessions(self, return_objects=False, return_profile_names=False): """\ STILL UNDOCUMENTED @@ -775,15 +797,77 @@ class X2goClient(object): if return_profile_names: return [ obj.get_profile_name() for obj in self.session_registry.suspended_sessions ] return [ obj.get_uuid() for obj in self.session_registry.suspended_sessions ] - __suspended_sessions = suspended_sessions + __client_suspended_sessions = client_suspended_sessions @property - def has_suspended_sessions(self): + def client_has_suspended_sessions(self): """\ STILL UNDOCUMENTED """ return self.session_registry.has_suspended_sessions + __client_has_suspended_sessions = client_has_suspended_sessions + + ### + ### Provide access to the X2go server's sessions DB + ### + + def server_running_sessions(self, session_uuid): + """\ + STILL UNDOCUMENTED + + """ + if self._X2goClient__is_session_connected(session_uuid): + session_list = self._X2goClient__list_sessions(session_uuid) + return [ key for key in session_list.keys() if session_list[key].status == 'R' ] + else: + raise X2goClientException('X2go session with UUID %s is not connected' % session_uuid) + __server_running_sessions = server_running_sessions + + @property + def server_has_running_sessions(self, session_uuid): + """\ + STILL UNDOCUMENTED + + """ + return len(self._X2goClient__server_running_sessions(session_uuid)) > 0 + __server_has_running_sessions = server_has_running_sessions + + @property + def server_has_running_session_of_name(self, session_uuid, session_name): + """\ + STILL UNDOCUMENTED + + """ + return session_name in self._X2goClient__server_running_sessions(session_uuid) + + def server_suspended_sessions(self, session_uuid): + """\ + STILL UNDOCUMENTED + + """ + if self._X2goClient__is_session_connected(session_uuid): + session_list = self._X2goClient__list_sessions(session_uuid) + return [ key for key in session_list.keys() if session_list[key].status == 'S' ] + else: + raise X2goClientException('X2go session with UUID %s is not connected' % session_uuid) + __server_suspended_sessions = server_suspended_sessions + + @property + def server_has_suspended_sessions(self): + """\ + STILL UNDOCUMENTED + + """ + return len(self._X2goClient__server_suspended_sessions(session_uuid)) > 0 + + @property + def server_has_suspended_session_of_name(self, session_uuid, session_name): + """\ + STILL UNDOCUMENTED + + """ + return session_name in self._X2goClient__server_suspended_sessions(session_uuid) ### ### CLIENT OPERATIONS ON SESSIONS (listing sessions, terminating non-associated sessions etc.) diff --git a/x2go/registry.py b/x2go/registry.py index 2634231..79c5da9 100644 --- a/x2go/registry.py +++ b/x2go/registry.py @@ -46,7 +46,6 @@ class X2goRegisteredSession(): self.logger = copy.deepcopy(logger) self.logger.tag = __NAME__ - self.session_command = {} self._keep_alive = True self.uuid = uuid.uuid1() @@ -152,12 +151,22 @@ class X2goRegisteredSession(): connect_options['username'] = username connect_options['force_password_auth'] = force_password_auth self.connected = self.session_object.connect(self.server, **connect_options) - session_command = {} return self.connected - __connect = connect - def set_print_action(self, session_uuid, print_action, **kwargs): + def disconnect(self): + """\ + STILL UNDOCUMENTED + + """ + self.session_object.disconnect() + self.connected = False + self.running = False + self.suspended = False + self.terminated = False + __disconnect = disconnect + + def set_print_action(self, print_action, **kwargs): """\ STILL UNDOCUMENTED @@ -188,7 +197,9 @@ class X2goRegisteredSession(): session.share_local_folder(_folder) session.run_command() + self.suspended = False self.running = True + self.terminated = False return self.running __start = start @@ -212,7 +223,9 @@ class X2goRegisteredSession(): if self.printing: self.session_object.start_printing() + self.suspended = False self.running = True + self.terminated = False return True return False diff --git a/x2go/session.py b/x2go/session.py index f39cda5..8d42f0f 100644 --- a/x2go/session.py +++ b/x2go/session.py @@ -606,6 +606,13 @@ class X2goSession(paramiko.SSHClient): return (self.get_transport() is not None) + def disconnect(self): + """\ + STILL UNDOCUMENTED + + """ + self.get_transport().close() + def start(self, **kwargs): """\ Start a new X2go session. 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).