[X2Go-Commits] pyhoca-gui.git - build-59a18b6e3b5d3f1dd8f07f26433d37fe5984a57d (branch) updated: 2689544a7184a8509b4c5ed4021b1f560f4894e6

X2Go dev team git-admin at x2go.org
Tue Aug 27 13:20:36 CEST 2013


The branch, build-59a18b6e3b5d3f1dd8f07f26433d37fe5984a57d has been updated
       via  2689544a7184a8509b4c5ed4021b1f560f4894e6 (commit)
      from  a1c77b0af5b5f817b501d40574ca382d58922345 (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:
 pyhoca-gui               |    4 +++-
 pyhoca/wxgui/frontend.py |   49 +++++++++++++++++++++++++++++++++++-----------
 pyhoca/wxgui/logon.py    |    6 +-----
 3 files changed, 42 insertions(+), 17 deletions(-)

The diff of changes is:
diff --git a/pyhoca-gui b/pyhoca-gui
index 53c2e62..2b1508f 100755
--- a/pyhoca-gui
+++ b/pyhoca-gui
@@ -77,7 +77,9 @@ x2go_gui_options = [
                    {'args':['-P','--session-profile'], 'default': None, 'help': 'directly connect to a session profile', },
                    {'args':['--auto-connect'], 'default': False, 'action': 'store_true', 'help': 'connect sessions via SSH pubkey authentication if possible', },
                    {'args':['--start-on-connect'], 'default': False, 'action': 'store_true', 'help': 'start a session directly after authentication', },
-                   {'args':['--resume-on-connect'], 'default': False, 'action': 'store_true', 'help': 'if there is only one session it will be auto-resume', },
+                   {'args':['--resume-newest-on-connect', '--resume-on-connect'], 'default': False, 'action': 'store_true', 'help': ' on connect auto-resume the newest suspended session', },
+                   {'args':['--resume-oldest-on-connect'], 'default': False, 'action': 'store_true', 'help': ' on connect auto-resume the oldest suspended session', },
+                   {'args':['--resume-all-on-connect'], 'default': False, 'action': 'store_true', 'help': 'auto-resume all suspended session on connect', },
                  ]
 
 def parseargs():
diff --git a/pyhoca/wxgui/frontend.py b/pyhoca/wxgui/frontend.py
index 9e8f5d7..b0297e2 100644
--- a/pyhoca/wxgui/frontend.py
+++ b/pyhoca/wxgui/frontend.py
@@ -196,7 +196,9 @@ class PyHocaGUI(wx.App, x2go.X2goClient):
                 gevent.spawn(self._auto_connect, session_uuid)
 
         self.start_on_connect = self.args.start_on_connect
-        self.resume_on_connect =self.args.resume_on_connect
+        self.resume_newest_on_connect =self.args.resume_newest_on_connect
+        self.resume_oldest_on_connect =self.args.resume_oldest_on_connect
+        self.resume_all_on_connect =self.args.resume_all_on_connect
 
     def _auto_connect(self, session_uuid):
 
@@ -224,15 +226,45 @@ class PyHocaGUI(wx.App, x2go.X2goClient):
         if not self._X2goClient__list_sessions(session_uuid):
             self.OnSessionStart(evt)
 
-    def _resume_on_connect(self, evt, session_uuid):
+    def _resume_newest_on_connect(self, evt, session_uuid):
         session_infos = self._X2goClient__list_sessions(session_uuid)
-        if session_infos:
+        if session_infos: 
             newest_session_name = x2go.utils.session_names_by_timestamp(session_infos)[-1]
-            self._eventid_sessionnames_map[evt.GetId()] = newest_session_name
-            self.OnSessionResume(evt)
+            self._resume_on_connect(evt, session_uuid, newest_session_name)
             return True
         return False
 
+    def _resume_oldest_on_connect(self, evt, session_uuid):
+        session_infos = self._X2goClient__list_sessions(session_uuid)
+        if session_infos:
+            newest_session_name = x2go.utils.session_names_by_timestamp(session_infos)[0]
+            self._resume_on_connect(evt, session_uuid, newest_session_name)
+            return True
+        return False
+
+    def _resume_all_on_connect(self, evt, session_uuid):
+        session_infos = self._X2goClient__list_sessions(session_uuid)
+        if session_infos:
+            for session_name in session_infos.keys():
+                self._resume_on_connect(evt, session_uuid, session_name)
+            return True
+        return False
+
+    def _resume_on_connect(self, evt, session_uuid, session_name):
+        self._eventid_sessionnames_map[evt.GetId()] = session_name
+        self.OnSessionResume(evt)
+
+    def _post_authenticate(self, evt, session_uuid):
+        # try SSH key auth first
+        if self.resume_newest_on_connect:
+            _resumed = self._resume_newest_on_connect(evt, session_uuid)
+        elif self.resume_oldest_on_connect:
+            _resumed = self._resume_oldest_on_connect(evt, session_uuid)
+        elif self.resume_all_on_connect:
+            _resumed = self._resume_all_on_connect(evt, session_uuid)
+        if not _resumed and self.start_on_connect:
+            self._start_on_connect(evt, session_uuid)
+
     def OnSessionAuthenticate(self, evt):
         """\
         STILL UNDOCUMENTED
@@ -242,15 +274,10 @@ class PyHocaGUI(wx.App, x2go.X2goClient):
         self.current_profile_name = profile_name
         session_uuid = self._X2goClient__register_session(profile_name=self.current_profile_name)
         try:
-            # try SSH key auth first
             self._X2goClient__connect_session(session_uuid)
-            if self.resume_on_connect:
-                _resumed = self._resume_on_connect(evt, session_uuid)
-            if not _resumed and self.start_on_connect:
-                self._start_on_connect(evt, session_uuid)
+            self._post_authenticate(evt, session_uuid)
         except x2go.AuthenticationException:
             logon.PyHocaGUI_DialogBoxPassword(self, caller=self, current_profile_name=profile_name)
-
         if self._X2goClient__is_session_connected(session_uuid):
             self._pyhoca_logger('authentication to server has been successful', x2go.loglevel_INFO, )
         else:
diff --git a/pyhoca/wxgui/logon.py b/pyhoca/wxgui/logon.py
index 9285d46..6f3e240 100644
--- a/pyhoca/wxgui/logon.py
+++ b/pyhoca/wxgui/logon.py
@@ -167,11 +167,7 @@ class PyHocaGUI_DialogBoxPassword(sc.SizedFrame):
 
         session_uuid = self._PyHocaGUI._X2goClient__client_registered_sessions_of_name(self.current_profile_name)[0].get_uuid()
         self._PyHocaGUI._X2goClient__connect_session(session_uuid, username=username, password=password, force_password_auth=True)
-        if self._PyHocaGUI.resume_on_connect:
-            _resumed = self._PyHocaGUI._resume_on_connect(evt, session_uuid)
-        if not _resumed and self._PyHocaGUI.start_on_connect:
-            self._PyHocaGUI._start_on_connect(evt, session_uuid)
-
+        self._PyHocaGUI._post_authenticate(evt, session_uuid)
         self.Destroy()
 
     def OnCancel(self, evt):


hooks/post-receive
-- 
pyhoca-gui.git (Python X2Go Client (wxPython GUI))

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 "pyhoca-gui.git" (Python X2Go Client (wxPython GUI)).




More information about the x2go-commits mailing list