The branch, master has been updated via 1b8e6a3ffe35e2068d27220399c4f179e0542d10 (commit) from a04eec2fc959054572bed038ede4824ac379d11b (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 1b8e6a3ffe35e2068d27220399c4f179e0542d10 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Sun Sep 25 23:40:02 2011 +0200 Improve local session cache dir removal. ----------------------------------------------------------------------- Summary of changes: x2go/backends/control/_stdout.py | 8 ++++---- x2go/backends/terminal/_stdout.py | 33 ++++++++++++++++++++++++++------- x2go/client.py | 4 +++- x2go/session.py | 11 +++++++---- 4 files changed, 40 insertions(+), 16 deletions(-) The diff of changes is: diff --git a/x2go/backends/control/_stdout.py b/x2go/backends/control/_stdout.py index 5b5b63a..74bc797 100644 --- a/x2go/backends/control/_stdout.py +++ b/x2go/backends/control/_stdout.py @@ -758,7 +758,7 @@ class X2goControlSessionSTDOUT(paramiko.SSHClient): return _listsessions - def clean_sessions(self): + def clean_sessions(self, destroy_terminals=True): """\ Find X2go terminals that have previously been started by the connected user on the remote X2go server and terminate them. @@ -766,7 +766,7 @@ class X2goControlSessionSTDOUT(paramiko.SSHClient): """ session_list = self.list_sessions() for session_name in session_list.keys(): - self.terminate(session_name=session_name) + self.terminate(session_name=session_name, destroy_terminals=destroy_terminals) def is_connected(self): """\ @@ -873,7 +873,7 @@ class X2goControlSessionSTDOUT(paramiko.SSHClient): return _ret - def terminate(self, session_name): + def terminate(self, session_name, destroy_terminals=True): """\ Terminate either this or another available X2go session on the connected server. @@ -898,7 +898,7 @@ class X2goControlSessionSTDOUT(paramiko.SSHClient): dummy_stdout = stdout.read() dummy_stderr = stderr.read() if self.associated_terminals.has_key(session_name): - if self.associated_terminals[session_name] is not None: + if self.associated_terminals[session_name] is not None and destroy_terminals: self.associated_terminals[session_name].__del__() try: del self.associated_terminals[session_name] except KeyError: pass diff --git a/x2go/backends/terminal/_stdout.py b/x2go/backends/terminal/_stdout.py index c48bcd2..7289d80 100644 --- a/x2go/backends/terminal/_stdout.py +++ b/x2go/backends/terminal/_stdout.py @@ -326,6 +326,8 @@ class X2goTerminalSessionSTDOUT(object): else: self.session_info = info_backend() + self._cleaned_up = False + def __del__(self): self._x2go_tidy_up() @@ -351,7 +353,6 @@ class X2goTerminalSessionSTDOUT(object): except AttributeError: pass - # destroy current session information self.session_info.clear() def _mk_sessions_rootdir(self, d): @@ -367,8 +368,13 @@ class X2goTerminalSessionSTDOUT(object): def _rm_session_dirtree(self): - if self.session_info: - shutil.rmtree(self.session_info.name, ignore_errors=True) + if self.session_info.name: + shutil.rmtree('%s/S-%s' % (self.params.rootdir, self.session_info), ignore_errors=True) + + def _rm_desktop_dirtree(self): + + if self.session_info.display: + shutil.rmtree('%s/S-%s' % (self.params.rootdir, self.session_info.display), ignore_errors=True) def get_session_name(self): """\ @@ -1029,8 +1035,10 @@ class X2goTerminalSessionSTDOUT(object): @rtype: bool """ - self.control_session.terminate(session_name=self.session_info.name) + self.control_session.terminate(session_name=self.session_info.name, destroy_terminals=False) self.release_proxy() + self.post_terminate_cleanup() + self.__del__() # TODO: check if session has really suspended _ret = True @@ -1050,7 +1058,18 @@ class X2goTerminalSessionSTDOUT(object): STILL UNDOCUMENTED """ - # if we run in debug mode, we keep local session directories - if self.logger.get_loglevel() & log.loglevel_DEBUG != log.loglevel_DEBUG: + # this method might be called twice (directly and from update_status in the session + # registry instance. So we have to make sure, that this code will not fail + # if called twice. + if not self._cleaned_up and self.session_info.name: + # otherwise we wipe the session files locally - self._rm_session_dirtree() + self.logger('cleaning up session %s after termination' % self.session_info, loglevel=log.loglevel_NOTICE) + + # if we run in debug mode, we keep local session directories + if self.logger.get_loglevel() & log.loglevel_DEBUG != log.loglevel_DEBUG: + + self._rm_session_dirtree() + self._rm_desktop_dirtree() + + self._cleaned_up = True diff --git a/x2go/client.py b/x2go/client.py index 4ff7cd1..e8b85b5 100644 --- a/x2go/client.py +++ b/x2go/client.py @@ -319,6 +319,7 @@ class X2goClient(object): refresh_interval=refresh_interval, logger=self.logger ) + self.auto_update_sessionregistry = auto_update_sessionregistry if use_listsessions_cache: self.listsessions_cache = X2goListSessionsCache(self, logger=self.logger) @@ -2010,8 +2011,9 @@ class X2goClient(object): @type session_uuid: C{str} """ + _destroy_terminals = not ( self.auto_update_sessionregistry == True) session = self.session_registry(session_uuid) - session.clean_sessions() + session.clean_sessions(destroy_terminals=_destroy_terminals) __clean_sessions = clean_sessions def list_sessions(self, session_uuid=None, diff --git a/x2go/session.py b/x2go/session.py index ddb8b3b..65c9689 100644 --- a/x2go/session.py +++ b/x2go/session.py @@ -853,13 +853,13 @@ class X2goSession(object): return self.connected __is_alive = is_alive - def clean_sessions(self): + def clean_sessions(self, destroy_terminals=True): """\ Clean all running sessions for the authenticated user on the remote X2go server. """ if self.is_alive(): - self.control_session.clean_sessions() + self.control_session.clean_sessions(destroy_terminals=destroy_terminals) else: self._X2goSession__disconnect() __clean_sessions = clean_sessions @@ -1514,10 +1514,13 @@ class X2goSession(object): self.terminal_session.release_proxy() # unmount shared folders - self.unshare_all_local_folders() + try: + self.unshare_all_local_folders() + except X2goSessionException: + pass # remove client-side session cache - if self.terminated: + if self.terminated and self.has_terminal_session(): self.terminal_session.post_terminate_cleanup() # destroy terminal 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).