[X2Go-Commits] [pyhoca-gui] 02/02: Gracefully handle "Connection refused" errors after a broker login has already been successful.

git-admin at x2go.org git-admin at x2go.org
Sat Apr 5 01:19:03 CEST 2014


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

x2go pushed a commit to branch master
in repository pyhoca-gui.

commit 82848688e04e5daf9e31976cdd0d330e24a7b5e7
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Sat Apr 5 01:18:58 2014 +0200

    Gracefully handle "Connection refused" errors after a broker login has already been successful.
---
 debian/changelog         |    2 ++
 pyhoca/wxgui/frontend.py |   52 ++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index ba15158..e883e27 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -34,6 +34,8 @@ pyhoca-gui (0.5.0.0-0x2go1) UNRELEASED; urgency=low
       with SSL certificates that have been self-signed against a non-public
       root-CA certificate file.
     - Handle "Connection refused" errors during broker login attempts.
+    - Gracefully handle "Connection refused" errors after a broker login has already
+      been successful.
     - Update English / German translation.
 
  -- Mike Gabriel <mike.gabriel at das-netzwerkteam.de>  Wed, 08 Jan 2014 21:28:37 +0100
diff --git a/pyhoca/wxgui/frontend.py b/pyhoca/wxgui/frontend.py
index 08f9953..324d7ce 100644
--- a/pyhoca/wxgui/frontend.py
+++ b/pyhoca/wxgui/frontend.py
@@ -371,7 +371,10 @@ class PyHocaGUI(wx.App, x2go.X2GoClient):
                 if not self.args.single_session_profile:
                     self.auto_connect = True
                 self._pyhoca_logger('opening default session profile %s' % profile_name, loglevel=x2go.log.loglevel_NOTICE)
-                self._X2GoClient__register_session(profile_name=profile_name, auto_connect=self.auto_connect)
+                try:
+                    self._X2GoClient__register_session(profile_name=profile_name, auto_connect=self.auto_connect)
+                except x2go.x2go_exceptions.X2GoBrokerConnectionException:
+                    self.session_registration_failed(profile_name=profile_name)
 
         if self.auto_connect or self.broker_autoconnect:
             gevent.spawn(self._auto_connect)
@@ -819,7 +822,10 @@ class PyHocaGUI(wx.App, x2go.X2GoClient):
             return
         self.taskbar.SetIconConnecting(profile_name)
         if session_uuid is None:
-            session_uuid = self._X2GoClient__register_session(profile_name=profile_name)
+            try:
+                session_uuid = self._X2GoClient__register_session(profile_name=profile_name)
+            except x2go.x2go_exceptions.X2GoBrokerConnectionException:
+                self.session_registration_failed(profile_name)
         if session_uuid:
             self._temp_disabled_profile_names.append(profile_name)
             gevent.spawn(self._do_authenticate, evt, session_uuid)
@@ -1648,6 +1654,19 @@ class PyHocaGUI(wx.App, x2go.X2GoClient):
             self.WakeUpIdle()
             self.ExitMainLoop()
 
+    def session_registration_failed(self, profile_name='UNKNOWN', **kwargs):
+        """\
+        Notify about session registration failures.
+
+        @param profile_name: profile name of session that called this hook method
+        @type profile_name: C{str}
+
+        """
+        self.notifier.send(_(u'%s - session failure') % profile_name, _(u'The session initialization failed.'), icon='session_error', timeout=10000)
+        if self.exit_on_disconnect:
+            self.WakeUpIdle()
+            self.ExitMainLoop()
+
     def HOOK_desktop_sharing_denied(self, profile_name='UNKNOWN', **kwargs):
         """\
         Notify about the denial of desktop sharing by the other user.
@@ -1981,3 +2000,32 @@ class PyHocaGUI(wx.App, x2go.X2GoClient):
             evt.SetId(_dummy_id)
             self.OnServerDisconnect(evt)
 
+    def HOOK_broker_ignore_connection_problems(self, profile_name='UNKNOWN', is_profile_connected=False, **kwargs):
+        """\
+        Query about what to do with broker connection failures.
+
+        @param profile_name: profile name of a session that triggered this hook method
+        @type profile_name: C{str}
+        @param is_profile_connected: C{True} if the given session profile is already conneced to the server
+        @type is_profile_connected: C{bool}
+
+        @return: C{true} if session startup shall be attempted anyway, even if session
+            broker is down.
+        @rtype: C{bool}
+
+        """
+        if is_profile_connected:
+            m = messages.PyHoca_MessageWindow_OkCancel(self,
+                                                       title=_(u'%s: connection failure') % self.broker_name,
+                                                       msg=_(u"While initializing a session for profile '%s' the connection\nto %s has failed.\n\nIt is possible to attempt session initialization anyway. Do you\nwant to continue?") % (profile_name, self.broker_name),
+                                                       icon='warning',
+                                                       profile_name=profile_name)
+        else:
+            m = messages.PyHoca_MessageWindow_OkCancel(self,
+                                                       title=_(u'%s: connection failure') % self.broker_name,
+                                                       msg=_(u"While connecting to profile '%s' the connection\nto %s has failed.\n\nIt is possible to attempt session initialization anyway. Do you\nwant to continue?") % (profile_name, self.broker_name),
+                                                       icon='warning',
+                                                       profile_name=profile_name)
+
+        m.ShowModal()
+        return m.Ok()

--
Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/pyhoca-gui.git



More information about the x2go-commits mailing list