[X2Go-Commits] pyhoca-gui.git - twofactorauth (branch) updated: 48069d455581d22d4e48283f5056cfa325ef53ff

X2Go dev team git-admin at x2go.org
Sat Sep 14 15:54:11 CEST 2013


The branch, twofactorauth has been updated
       via  48069d455581d22d4e48283f5056cfa325ef53ff (commit)
      from  7a8808f258f6a417a9fe4d73b84a03e803841155 (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.py |    3 +-
 x2goLogon.py  |   93 +++++++++++++++++++++++++++++++++++++--------------------
 2 files changed, 63 insertions(+), 33 deletions(-)

The diff of changes is:
diff --git a/pyhoca-gui.py b/pyhoca-gui.py
index 7136187..aa3ea23 100644
--- a/pyhoca-gui.py
+++ b/pyhoca-gui.py
@@ -159,7 +159,7 @@ def check_running(logger):
     if platform.system() in ('Linux', 'Mac'):
         p = Popen(['ps', '-A'], stdout=PIPE)
         psA_out = p.communicate()
-        logger('psa_out %s' % (psA_out,), x2go.loglevel_INFO )
+        logger('psa_out %s' % (psA_out,), x2go.loglevel_DEBUG )
         return psA_out[0].count(PROG_NAME) > 1
     elif platform.system() == 'Windows':
         return False
@@ -172,3 +172,4 @@ def main():
 
 if __name__ == '__main__':
     main()
+  
\ No newline at end of file
diff --git a/x2goLogon.py b/x2goLogon.py
index 92960bf..7d3aac5 100644
--- a/x2goLogon.py
+++ b/x2goLogon.py
@@ -37,6 +37,7 @@ from Message import Message
 import x2go
 import pyhocaguiImages
 import platform
+import types
 
 try:
     from agw import knobctrl as KC
@@ -66,10 +67,12 @@ class menuActions(wx.Menu):
             self.settingsProfile = parent.settingsProfile
             self.SessionProfiles = parent.SessionProfiles
             self.printProfile = parent.printProfile
+            self.registeredSessions = parent.registeredSessions
         else:
             self.settingsProfile = parent.parent.settingsProfile
             self.SessionProfiles = parent.parent.SessionProfiles
             self.printProfile = parent.parent.printProfile
+            self.registeredSessions = parent.parent.registeredSessions
         if hasattr(parent,'selected_profile'):
             self.selected_profile = parent.selected_profile
         else:
@@ -95,19 +98,20 @@ class menuActions(wx.Menu):
         self.logger('settingsProfile.newProfile %s' % dir(self.settingsProfile), x2go.loglevel_INFO, )
         self.Append(MENU_NEWSESSION, OPENNEWMENUTXT)
         parent.Bind(wx.EVT_MENU, self.OnNewSession, id=MENU_NEWSESSION)
-        if self.settingsProfile.newprofile:
+        if self.settingsProfile.get('Authorization','newprofile',types.BooleanType):
             self.Append(MENU_NEWPROFILE, ADDPROFILEMENUTXT)
             parent.Bind(wx.EVT_MENU, self.OnAddProfile, id=MENU_NEWPROFILE)
-        if self.SessionProfiles.runningSessions() and popupMenu is False:
+        if self.registeredSessions.has_running_session and popupMenu is False:
             self.Append(MENU_LISTSESSIONS, RUNNINGMENUTXT)
             parent.Bind(wx.EVT_MENU, self.OnListSessions, id=MENU_LISTSESSIONS)
-        if self.settingsProfile.suspend and ((popupMenu is False and self.SessionProfiles.runningSessions()) or (popupMenu and self.selected_profile.connected is False and self.selected_profile.isAlive())):
+        if self.settingsProfile.get('Authorization','suspend',types.BooleanType) and ((popupMenu is False and self.registeredSessions.has_running_session) 
+            or (popupMenu and self.registeredSessions.running_sessions_of_name(self.parent.selected_profile['name']) is False and self.selected_profile.session_ok())):
             self.Append(MENU_SUSPEND, SUSPENDMENUTXT)
             parent.Bind(wx.EVT_MENU, self.OnSuspend, id=MENU_SUSPEND)
-        if self.settingsProfile.resume and self.SessionProfiles.suspendedSessions():
+        if self.settingsProfile.get('Authorization','resume',types.BooleanType) and self.registeredSessions.has_suspended_session:
             self.Append(MENU_RESUME, RESUMEMENUTXT)
             parent.Bind(wx.EVT_MENU, self.OnResume, id=MENU_RESUME)
-        if self.settingsProfile.editprofile:
+        if self.settingsProfile.get('Authorization','editprofile',types.BooleanType):
             self.AppendSeparator()
             self.Append(MENU_EDITSESSION, UPDATEPROFMNUTEXT)
             parent.Bind(wx.EVT_MENU, self.OnUpdateProfile, id=MENU_EDITSESSION)
@@ -121,7 +125,6 @@ class menuActions(wx.Menu):
         X2goMaintProfile.X2goMaintProfile('Add', self.parent, self.SessionProfiles, self.parent.callbackupdList)
 
     def OnNewSession(self, evt):
-        self.logger('NewSession started for self.parent.__class__.__name__ %s, len(self.SessionProfiles.x2goprofs) %s' % (self.parent.__class__.__name__, len(self.SessionProfiles.x2goprofs)), x2go.loglevel_INFO, )
         if hasattr(self.parent,'selected_profile'):
             X2GoPasswordScrn(self.parent)
         elif len(self.SessionProfiles.x2goprofs) > 1:
@@ -196,7 +199,7 @@ class X2GoPasswordScrn(sc.SizedFrame):
         if the screen is iconized, but an error occurs, the screen is displayed
         and the user can enter another userid/password
         """
-        captionText = "X2go Profile " + parent.current_profile.name
+        captionText = "X2go Profile " + parent.current_profile['name']
         sc.SizedFrame.__init__(self, None, -1, captionText,
                         style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
         self.CentreOnScreen()
@@ -206,6 +209,7 @@ class X2GoPasswordScrn(sc.SizedFrame):
         self.settingsProfile = parent.settingsProfile
         self.SessionProfiles = parent.SessionProfiles
         self.current_profile = parent.current_profile
+        self.registeredSessions = parent.registeredSessions        
         self.printProfile = parent.printProfile
         self.parent = parent
         self.logger = parent.logger
@@ -247,24 +251,25 @@ class X2GoPasswordScrn(sc.SizedFrame):
         if len(password) == 0:
             Message(self,2)
             return
-        self.current_profile.updValue('username',username)
-        self.current_profile.setPassword(password)
-        self.onConnect()
+        self.onConnect(username, password)
 
-    def onConnect(self):
+    def onConnect(self, username, password):
         error = True
+        profile_name = self.current_profile['name']
+        profile_id = self.SessionProfiles.to_profile_id(profile_name)
         try:
-            connection = self.current_profile.Connect(self)
-            connection.makeConnection(self.session, self.StatusText)
+            session_uuid = self.registeredSessions.register(profile_id, profile_name)
+            self.registeredSessions(session_uuid).connect(password=password)
+            self.registeredSessions(session_uuid).start()
             error = False
         except x2go.AuthenticationException:
             Message(self,3)
         except x2go.BadHostKeyException:
-            Message(self,message='SSH host key verification for remote host [%s]:%s failed' % (self.current_profile.host, self.current_profile.sshport ))
+            Message(self,message='SSH host key verification for remote host [%s]:%s failed' % (self.current_profile['host'], self.current_profile['sshport'] ))
         except x2go.SSHException, e:
-            Message(self,message='Problem with ssh tunnel for host [%s]:%s failed' % (self.current_profile.host, self.current_profile.sshport ))
+            Message(self,message='Problem with ssh tunnel for host [%s]:%s failed' % (self.current_profile['host'], self.current_profile['sshport'] ))
         except:
-            Message(self,message='Unknown problem with connection to host [%s]:%s' % (self.current_profile.host, self.current_profile.sshport ))
+            Message(self,message='Unknown problem with connection to host [%s]:%s' % (self.current_profile['host'], self.current_profile['sshport'] ))
         if error:
             self.Show(True)
             if self.IsIconized():
@@ -310,6 +315,7 @@ class X2GoChooseSessionScrn(wx.Frame):
         self.currentItem = None
         self.printProfile = parent.printProfile
         self.logger('Choose Session screen started iconize %s' % Iconize, x2go.loglevel_INFO, )
+        if self.current_profile: self.logger('With current session %s' % self.current_profile['name'], x2go.loglevel_INFO, )
         wx.Frame.__init__(self, None, -1)
         self.CentreOnScreen()
         self.il = wx.ImageList(16, 16)
@@ -369,23 +375,45 @@ class X2GoChooseSessionScrn(wx.Frame):
         self.list.InsertColumnInfo(0, info)
 
         info.m_format = wx.LIST_FORMAT_RIGHT
-        info.m_text = "Status"
+        info.m_text = ""
         self.list.InsertColumnInfo(1, info)
-        for profilename, connected, alive in sessions:
-            self.addRow(profilename, connected, alive)
 
+        info.m_format = wx.LIST_FORMAT_RIGHT
+        info.m_text = "Status"
+        self.list.InsertColumnInfo(2, info)
+
+        info.m_format = wx.LIST_FORMAT_RIGHT
+        info.m_text = "Sessie-Id"
+        self.list.InsertColumnInfo(3, info)
+
+        self.logger('sessions %s' % sessions, x2go.loglevel_INFO, )
+        for profilename in sessions:
+            registeredProfiles = self.registeredSessions.registered_sessions_of_name(profilename)
+            if len(registeredProfiles):
+                for idx, session in enumerate(registeredProfiles):
+                    if len(registeredProfiles) > 1:
+                        prName = profilename
+                    else:
+                        prName = profilename
+                    self.addRow(prName, idx, session, session.connected, session.is_running(), session.is_suspended(), sessions.session_ok())
+            else:
+                self.addRow(profilename)
         self.list.SetColumnWidth(0, wx.LIST_AUTOSIZE)
 
-    def addRow(self, profilename, connected, alive):
-        if connected and alive:
-            index = self.list.InsertImageStringItem(sys.maxint, profilename, self.idx2)
-            self.list.SetStringItem(index, 1, 'Connected')
-        elif not connected and alive:
-            index = self.list.InsertImageStringItem(sys.maxint, profilename, self.idx3)
-            self.list.SetStringItem(index, 1, 'Suspended')
+    def addRow(self, profilename, idx='', sessionName=None, connected=False, running=False, suspended=False, alive=False):
+        if connected and alive and running:
+            imageNr = self.idx2
+            statusText = 'Connected'
+        elif suspended or (not connected and (alive or running)):
+            imageNr = self.idx3
+            statusText = 'Suspended'
         else:
-            index = self.list.InsertImageStringItem(sys.maxint, profilename, self.idx1)
-            self.list.SetStringItem(index, 1, 'Not Connected')
+            imageNr = self.idx1
+            statusText = 'Not Connected'
+        index = self.list.InsertImageStringItem(sys.maxint, profilename, imageNr)
+        self.list.SetStringItem(index, 1, str(idx))
+        self.list.SetStringItem(index, 2, statusText)
+        if sessionName: self.list.SetStringItem(index, 3, sessionName)
 
     def OnRightDown(self, event):
         x = event.GetX()
@@ -399,7 +427,7 @@ class X2GoChooseSessionScrn(wx.Frame):
     def OnItemSelected(self, event):
         ##print event.GetItem().GetTextColour()
         self.currentItem = event.m_itemIndex
-        self.selected_profile = self.parent.SessionProfiles.getProfileByName(self.list.GetItemText(self.currentItem))
+        self.selected_profile = self.parent.SessionProfiles.get_profile_config(self.list.GetItemText(self.currentItem))
 
     def OnDoubleClick(self, event):
         self.logger('DoubleClick', x2go.loglevel_INFO, )
@@ -407,7 +435,7 @@ class X2GoChooseSessionScrn(wx.Frame):
 
     def OnItemActivated(self, event):
         self.currentItem = event.m_itemIndex
-        self.selected_profile = self.parent.SessionProfiles.getProfileByName(self.list.GetItemText(self.currentItem))
+        self.selected_profile = self.SessionProfiles.get_profile_config(self.list.GetItemText(self.currentItem))
 
     def OnRightClick(self, event):
         # only do this part the first time so the events are only bound once
@@ -417,7 +445,7 @@ class X2GoChooseSessionScrn(wx.Frame):
         self.PopupMenu(menuActions(self, popupMenu=True))
 
     def OnCancel(self, evt):
-        if not self.SessionProfiles.anyRunningSessions():
+        if not self.registeredSessions.has_running_session:
         #self.Close()
             self.tb.Destroy()
         self.Destroy()
@@ -540,7 +568,7 @@ def startX2Go(parent):
     parent.registeredSessions = x2go.registry.X2goSessionRegistry(logger=parent.liblogger)
 
     sessionsSuspended = parent.registeredSessions.suspended_sessions
-    parent.current_profile = defaultProfile = parent.SessionProfiles.has_default_profile()
+    parent.current_profile = defaultProfile = parent.SessionProfiles.get_default_profile()
     if sessionsSuspended and len(sessionsSuspended) > 0:
         if parent.settingsProfile.autoresume:
             parent.logger('autoresume sessionsSuspended %s' % sessionsSuspended, x2go.loglevel_INFO, )
@@ -558,3 +586,4 @@ def startX2Go(parent):
     else:
         parent.logger('Start Profile Definition', x2go.loglevel_INFO, )
         defScrn = X2GoSessionDefScrn(parent, directCall=True)
+  
\ No newline at end of file


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