[X2Go-Commits] [x2goclient] 15/94: * improved error handling for crash X2go session (integration in to PyHoca-CLI)

git-admin at x2go.org git-admin at x2go.org
Fri Dec 15 21:04:32 CET 2023


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to annotated tag 0.1.4.0
in repository x2goclient.

commit 7e59b3d16f0622bd210ef0ca23c0106b608a8c40
Author: mike <mike at cdb5e8f1-f799-4276-8919-bce57fd91830>
Date:   Wed Nov 10 14:51:29 2010 +0000

    * improved error handling for crash X2go session (integration in to PyHoca-CLI)
    
    
    git-svn-id: https://svn.das-netzwerkteam.de/x2go/pyhoca-cli/trunk@46 cdb5e8f1-f799-4276-8919-bce57fd91830
---
 pyhoca/cli/frontend.py | 64 ++++++++++++++++++++++++++++++--------------------
 1 file changed, 38 insertions(+), 26 deletions(-)

diff --git a/pyhoca/cli/frontend.py b/pyhoca/cli/frontend.py
index 5aae849e..e19cda89 100644
--- a/pyhoca/cli/frontend.py
+++ b/pyhoca/cli/frontend.py
@@ -28,6 +28,7 @@ import getpass
 import x2go
 import paramiko
 from types import *
+from gevent import socket
 
 # a list of available X2go print actions
 from x2go.defaults import X2GO_PRINT_ACTIONS
@@ -233,19 +234,24 @@ class PyHocaCLI(x2go.X2goClient):
         """
         connected = False
         force_password_auth = False
-        while not connected:
-            try:
-                self._X2goClient__connect_session(self.x2go_session_hash, password=self.args.password, force_password_auth=force_password_auth)
-                connected = True
-            except x2go.AuthenticationException:
-                force_password_auth = True
-                self.args.password = getpass.getpass()
-            except x2go.PasswordRequiredException:
-                self.args.password = getpass.getpass()
-            except x2go.BadHostKeyException:
-                self._runtime_error('SSH host key verification for remote host [%s]:%s failed' % (self.args.server, self.args.remote_ssh_port), exitcode=-254)
-            except x2go.SSHException, e:
-                self._runtime_error(str(e), exitcode=253)
+        try:
+
+            while not connected:
+                try:
+                    self._X2goClient__connect_session(self.x2go_session_hash, password=self.args.password, force_password_auth=force_password_auth)
+                    connected = True
+                except x2go.AuthenticationException:
+                    force_password_auth = True
+                    self.args.password = getpass.getpass()
+                except x2go.PasswordRequiredException:
+                    self.args.password = getpass.getpass()
+                except x2go.BadHostKeyException:
+                    self._runtime_error('SSH host key verification for remote host [%s]:%s failed' % (self.args.server, self.args.remote_ssh_port), exitcode=-254)
+                except x2go.SSHException, e:
+                    self._runtime_error(str(e), exitcode=253)
+
+        except socket.error, e:
+            self._runtime_error('a socket error occured while establishing the connection: %s' % str(e), exitcode=-245)
 
 
     def MainLoop(self):
@@ -302,19 +308,25 @@ class PyHocaCLI(x2go.X2goClient):
 
                 session_duration = 0
                 mounted = False
-                while self._X2goClient__session_ok(self.x2go_session_hash):
-                    time.sleep(2)
-                    session_duration +=2
-
-                    # wait a little longer before telling the user what had happened
-                    time.sleep(2)
-
-                if self._X2goClient__has_session_terminated(self.x2go_session_hash):
-                    self.logger("X2go session %s has terminated" % session_name, x2go.loglevel_NOTICE, )
-                elif self._X2goClient__is_session_suspended(self.x2go_session_hash):
-                    self.logger("X2go session %s has been suspended" % session_name, x2go.loglevel_NOTICE, )
-                elif self._X2goClient__is_session_running(self.x2go_session_hash):
-                    self.logger("X2go session %s has been moved to a different screen" % session_name, x2go.loglevel_NOTICE, )
+
+                try:
+                    while self._X2goClient__session_ok(self.x2go_session_hash):
+                        time.sleep(2)
+                        session_duration +=2
+
+                        # wait a little longer before telling the user what had happened
+                        time.sleep(2)
+
+                    if self._X2goClient__has_session_terminated(self.x2go_session_hash):
+                        self.logger("X2go session %s has terminated" % session_name, x2go.loglevel_NOTICE, )
+                    elif self._X2goClient__is_session_suspended(self.x2go_session_hash):
+                        self.logger("X2go session %s has been suspended" % session_name, x2go.loglevel_NOTICE, )
+                    elif self._X2goClient__is_session_running(self.x2go_session_hash):
+                        self.logger("X2go session %s has been moved to a different screen" % session_name, x2go.loglevel_NOTICE, )
+
+                except x2go.X2goSessionException, e:
+                    self.logger("X2goSessionException occured:", x2go.loglevel_ERROR, )
+                    self.logger("-> %s" % str(e), x2go.loglevel_ERROR, )
 
             except KeyboardInterrupt:
                 self.logger("Suspending X2go session %s" % session_name, x2go.loglevel_INFO, )

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2goclient.git


More information about the x2go-commits mailing list