[X2Go-Commits] python-x2go.git - build-baikal (branch) updated: 0.2.0.1-4-g0983bbc

X2Go dev team git-admin at x2go.org
Wed Jan 8 15:31:08 CET 2014


The branch, build-baikal has been updated
       via  0983bbcce7c7ff1cfd98b9dd96045607fc2a8a1d (commit)
      from  44542ee31e44307378364c316a0539341abd3a0d (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/changelog                  |    1 +
 x2go/backends/control/_stdout.py  |   19 ++++++++++++-------
 x2go/backends/terminal/_stdout.py |    5 +++++
 x2go/session.py                   |   21 ++++++++++++++++-----
 4 files changed, 34 insertions(+), 12 deletions(-)

The diff of changes is:
diff --git a/debian/changelog b/debian/changelog
index ef52702..eff4c5b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,7 @@ python-x2go (0.2.0.2-0~x2go1) UNRELEASED; urgency=low
   * Bugfix release (0.2.0.2):
     - Be tolerant if we can not terminate a session after failure of the
       forwarding tunnel.
+    - Improve session management, handle exceptions more gracefully.
 
  -- Mike Gabriel <mike.gabriel at das-netzwerkteam.de>  Wed, 30 May 2012 00:27:03 +0200
 
diff --git a/x2go/backends/control/_stdout.py b/x2go/backends/control/_stdout.py
index a5c2fd6..06bef97 100644
--- a/x2go/backends/control/_stdout.py
+++ b/x2go/backends/control/_stdout.py
@@ -896,8 +896,11 @@ class X2goControlSessionSTDOUT(paramiko.SSHClient):
         @rtype: C{bool}
 
         """
-        if self._x2go_exec_command('echo', loglevel=log.loglevel_DEBUG):
-            return True
+        try:
+            if self._x2go_exec_command('echo', loglevel=log.loglevel_DEBUG):
+                return True
+        except x2go_exceptions.X2goControlSessionException:
+            pass
         return False
 
     def get_published_applications(self, lang=None, refresh=False, raw=False, very_raw=False, max_no_submenus=defaults.PUBAPP_MAX_NO_SUBMENUS):
@@ -1158,11 +1161,13 @@ class X2goControlSessionSTDOUT(paramiko.SSHClient):
                                            **kwargs)
 
         _success = False
-        if session_name is not None:
-            _success = _terminal.resume()
-
-        else:
-            _success = _terminal.start()
+        try:
+            if session_name is not None:
+                _success = _terminal.resume()
+            else:
+                _success = _terminal.start()
+        except x2go_exceptions.X2goTerminalSessionException:
+            _success = False
 
         if _success:
             while not _terminal.ok():
diff --git a/x2go/backends/terminal/_stdout.py b/x2go/backends/terminal/_stdout.py
index b1f1259..bcd6771 100644
--- a/x2go/backends/terminal/_stdout.py
+++ b/x2go/backends/terminal/_stdout.py
@@ -1440,6 +1440,9 @@ class X2goTerminalSessionSTDOUT(object):
             if self.params.published_applications:
                 self.control_session.get_published_applications()
 
+        else:
+            raise x2go_exceptions.X2goTerminalSessionException("failed to start X2Go session")
+
         return proxy_ok
 
     def resume(self):
@@ -1524,6 +1527,8 @@ class X2goTerminalSessionSTDOUT(object):
             if self.is_published_applications_provider():
                 self.control_session.get_published_applications()
                 self.published_applications = True
+        else:
+            raise x2go_exceptions.X2goTerminalSessionException("failed to start X2Go session")
 
         return proxy_ok
 
diff --git a/x2go/session.py b/x2go/session.py
index b157e8e..6350d0c 100644
--- a/x2go/session.py
+++ b/x2go/session.py
@@ -486,9 +486,9 @@ class X2goSession(object):
         @rtype: C{bool}
 
         """
-        if self.master_session is None:
+        if self.master_session is None and self.client_instance is None:
             return True
-        return self.master_session
+        return bool(self.master_session)
 
     def set_master_session(self, wait=0, max_wait=20):
         """\
@@ -586,6 +586,9 @@ class X2goSession(object):
         Class destructor.
 
         """
+        if self.is_connected():
+            self.disconnect()
+
         if self.has_control_session() and self.has_terminal_session():
             self.get_control_session().dissociate(self.get_terminal_session())
 
@@ -616,8 +619,6 @@ class X2goSession(object):
                 self.get_control_session().__del__()
                 self.control_session = None
 
-        self.master_session = None
-
         if self.has_terminal_session():
             self.get_terminal_session().__del__()
             self.terminal_session = None
@@ -1113,7 +1114,8 @@ class X2goSession(object):
         self.suspended = None
         self.terminated = None
         self.faults = None
-        self.master_session = None
+        self.active = False
+        self.unset_master_session()
         try:
             self.update_status(force_update=True)
         except x2go_exceptions.X2goControlSessionException:
@@ -1528,6 +1530,7 @@ class X2goSession(object):
                 try:
                     self.session_name = self.terminal_session.session_info.name
                 except AttributeError:
+                    # if self.terminal_session is None, we end up with a session failure...
                     self.HOOK_session_startup_failed()
                     return False
 
@@ -1708,10 +1711,13 @@ class X2goSession(object):
                 self.suspended = True
                 self.terminated = False
                 self.faulty = False
+                self.active = False
 
                 # unmount shared folders
                 self.unshare_all_local_folders(force_all=True)
 
+                self.unset_master_session()
+
                 if self.terminal_session.suspend():
 
                     self.session_cleanup()
@@ -1726,6 +1732,7 @@ class X2goSession(object):
                     self.suspended = True
                     self.terminated = False
                     self.faulty = False
+                    self.active = False
                     self.session_cleanup()
                     return True
 
@@ -1755,10 +1762,13 @@ class X2goSession(object):
                 self.suspended = False
                 self.terminated = True
                 self.faulty = False
+                self.active = False
 
                 # unmount shared folders
                 self.unshare_all_local_folders(force_all=True)
 
+                self.unset_master_session()
+
                 if self.terminal_session.terminate():
                     self.session_cleanup()
                     del self.terminal_session
@@ -1772,6 +1782,7 @@ class X2goSession(object):
                     self.suspended = False
                     self.terminated = True
                     self.faulty = False
+                    self.active = False
                     self.session_cleanup()
                     return True
             else:


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