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

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


The branch, twofactorauth has been updated
       via  e90dfa515174ef9c9256843034ca57e784cafbd5 (commit)
      from  81eeb4e708475585014567bb826564641777364b (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:
 SessionProfile.py |   12 ++++++-
 x2goLogon.py      |   98 +++++++++++++++++++++++++++++++++++------------------
 2 files changed, 76 insertions(+), 34 deletions(-)

The diff of changes is:
diff --git a/SessionProfile.py b/SessionProfile.py
index 40ca343..c3b976d 100644
--- a/SessionProfile.py
+++ b/SessionProfile.py
@@ -254,9 +254,12 @@ class SingleProfile:
 
     def updValue(self, key, value):
         setattr(self, key, value)
+        
+    def setPassword(self, password):
+        self.password = password
 
 class x2goProfiles:
-    def __init__(self, logger, liblogger):
+    def __init__(self, logger, liblogger, profile=None):
         self.logger = logger
         self.liblogger = liblogger
         self.x2goprofs = []
@@ -275,6 +278,13 @@ class x2goProfiles:
             self.current_profile = self.x2goprofs[0]
         for idx, prof in enumerate(self.x2goprofs):
             self.x2gonames[prof.name] = idx
+            
+        if profile:
+            if self.profileExists(profile):
+                self.current_profile = self.getProfileByName(profile)
+                self.there_is_a_default = True
+            else:
+                self.current_profile = None
 
     def AddProfile(self, name, **kw):
         if self.profileExists(name):
diff --git a/x2goLogon.py b/x2goLogon.py
index de101e4..fae9961 100644
--- a/x2goLogon.py
+++ b/x2goLogon.py
@@ -119,7 +119,7 @@ class menuActions(wx.Menu):
 
     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') and 1==0:
+        if hasattr(self.parent,'selected_profile'):
             X2GoPasswordScrn(self.parent)
         elif len(self.SessionProfiles.x2goprofs) > 1:
             self.logger('self.parent.IsIconized() %s' % self.parent.IsIconized(), x2go.loglevel_INFO, )
@@ -184,7 +184,7 @@ class X2GoResumeSessions(sc.SizedFrame):
                         style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
 
 class X2GoPasswordScrn(sc.SizedFrame):
-    def __init__(self, parent, Iconize=False):
+    def __init__(self, parent):
         """
         Screen to enter the userid and password for the session
 
@@ -208,32 +208,22 @@ class X2GoPasswordScrn(sc.SizedFrame):
         pane = self.GetContentsPane()
         pane.SetSizerType("form")
         pwScrn = self.passwordScrn(pane)
-        self.Main_MenuBar = wx.MenuBar()
-        self.SetMenuBar(self.Main_MenuBar)
-        self.Main_MenuBar.Append(menuActions(self), '&Connection')
-        #self.Bind(wx.EVT_CLOSE, self.OnCancel)
-        if Iconize:
-            if not self.IsIconized():
-                self.Iconize(True)
-            if parent.parent.args.password and parent.parent.args.username and parent.parent.args.profile and SessionProfiles.profileExists(parent.parent.args.profile):
-                self.onConnect()
-            elif parent.args.profile:
-                Message(self, 'Not all credentials are available')
-                self.Iconize(False)
+        self.Fit()
+        if parent.parent.args.password and parent.parent.args.username and self.current_profile:
+            self.onConnect()
         else:
             self.Show(True)
-        self.Fit()
 
     def passwordScrn(self, pnl):
-        wx.StaticText(pnl, -1, 'User'),
+        wx.StaticText(pnl, -1, '  User'),
         self.username_ctl = wx.TextCtrl(pnl, -1)
         self.username_ctl.SetSizerProps(expand=True)
         if hasattr(self.current_profile,'username'):
-            self.username_ctl.SetValue(self.SessionProfile.username)
+            self.username_ctl.SetValue(self.current_profile.username)
         else:
             self.username_ctl.SetValue(self.parent.parent.args.username)
 
-        wx.StaticText(pnl, -1, 'Password'),
+        wx.StaticText(pnl, -1, '  Password'),
         self.passwd_ctl = wx.TextCtrl(pnl, -1, style=wx.TE_PASSWORD)
 
         self.ConnectButton = wx.Button(pnl, -1, "Connect")
@@ -253,23 +243,32 @@ class X2GoPasswordScrn(sc.SizedFrame):
             Message(self,'Password is required')
             return
         self.current_profile.updValue('username',username)
-        self.current_profile.password = password
+        self.current_profile.setPassword(password)
         self.onConnect()
 
     def onConnect(self):
-        set_iconize = False
+        error = True
         try:
             connection = self.current_profile.Connect(self)
             connection.makeConnection(self.session, self.StatusText)
-            set_iconize = True
+            error = False
         except x2go.AuthenticationException:
             Message(self,'Userid/Password verification failed')
         except x2go.BadHostKeyException:
-            self.Message(self,'SSH host key verification for remote host [%s]:%s failed' % (self.current_profile.host, self.current_profile.ssh_port ))
+            Message(self,'SSH host key verification for remote host [%s]:%s failed' % (self.current_profile.host, self.current_profile.sshport ))
         except x2go.SSHException, e:
-            self.Message(self,'Problem with ssh tunnel for host [%s]:%s failed' % (self.current_profile.host, self.current_profile.ssh_port ))
-        if (set_iconize and not self.IsIconized()) or (self.IsIconized() and not set_iconize):
-            self.Iconize(set_iconize)
+            Message(self,'Problem with ssh tunnel for host [%s]:%s failed' % (self.current_profile.host, self.current_profile.sshport ))
+        except:
+            Message(self,'Unknown problem with connection to host [%s]:%s' % (self.current_profile.host, self.current_profile.sshport ))
+        if error:
+            self.Show(True)
+            if self.IsIconized():
+                self.Iconize(False)
+        else:
+            self.Show(False)
+            if not self.IsIconized():
+                self.Iconize(True)
+        self.parent.callbackConnection(error)
         return
 
     def OnCancel(self, evt):
@@ -302,8 +301,9 @@ class X2GoChooseSessionScrn(wx.Frame):
         self.SessionProfiles = parent.SessionProfiles
         self.current_profile = parent.SessionProfiles.current_profile
         self.selected_profile = None
+        self.currentItem = None
         self.printProfile = parent.printProfile
-        self.logger('Choose Session screen started', x2go.loglevel_INFO, )
+        self.logger('Choose Session screen started iconize %s' % Iconize, x2go.loglevel_INFO, )
         wx.Frame.__init__(self, None, -1)
         self.CentreOnScreen()
         self.il = wx.ImageList(16, 16)
@@ -341,6 +341,11 @@ class X2GoChooseSessionScrn(wx.Frame):
         if Iconize:
             if not self.IsIconized():
                 self.Iconize(True)
+            if parent.args.password and parent.args.username and self.current_profile:
+                X2GoPasswordScrn(self)
+            elif parent.args.profile:
+                Message(self, 'Not all credentials are available')
+                self.Iconize(False)
         else:
             self.Show(True)
 
@@ -407,6 +412,14 @@ class X2GoChooseSessionScrn(wx.Frame):
         #self.Close()
             self.tb.Destroy()
         self.Destroy()
+        
+    def callbackConnection(self, error):
+        if self.currentItem:
+            if error:
+                self.list.SetItemImage(self.currentItem, self.idx1)
+            else:
+                self.list.SetItemImage(self.currentItem, self.idx2)
+            
 
 class X2GoSessionDefScrn(wx.Frame):
     SESSIONNOTEBOOK = wx.NewId()
@@ -554,8 +567,7 @@ class X2GoLogonTaskBarIcon(wx.TaskBarIcon):
         wx.TaskBarIcon.__init__(self)
         self.parent = parent
         self.parent.parent.logger('Start TaskBarIcon type %s' % (wx.PlatformInfo, ), x2go.loglevel_INFO, )
-        img = wx.Image('Images/x2goclient.png')
-        icon = self.MakeIcon(img)
+        icon = self.MakeIcon(pyhocaguiImages.getx2goclientImage())
         self.SetIcon(icon, "x2go connect")
         self.imgidx = 1
 
@@ -641,16 +653,36 @@ def startX2Go(parent):
     This routine starts all processing
 
     If there is only one profile available, or if there is one (1) single
-    profile that has the default switch, the logon screen
-    can be shown immediately
+    profile that has the default switch, and the password has not been passed, 
+    the logon screen is shown immediately
+    
+    If there is only one profile available, or if there is one (1) single
+    profile that has the default switch, and the password has been passed, 
+    the connection can be made immediately and the screens should not be shown,
+    but if there is an error in the connection, the logon screen should be shown with an errormessage.
+    
+    if there are more than one profile available, and there is no default, 
+    the list of available profiles should be shown. After the user chooses
+    a profile, the connection should be made to that specific profile, turning
+    it into a session. After that all screens should be minimized.
+    
+    First all profile information is retrieved together with the settings and 
+    the printprofile. 
+    
+    Then it is tested if there are more than one profile that can be selected
     """
     parent.logger('starting a new X2go GUI session', x2go.loglevel_INFO, )
 
     parent.printProfile = SessionProfile.Printing(parent.logger)
     parent.settingsProfile = SessionProfile.Settings(parent.logger)
-    parent.SessionProfiles = SessionProfile.x2goProfiles(parent.logger, parent.liblogger)
+    if parent.args.profile:
+        parent.SessionProfiles = SessionProfile.x2goProfiles(parent.logger, parent.liblogger, parent.args.profile)
+    else:
+        parent.SessionProfiles = SessionProfile.x2goProfiles(parent.logger, parent.liblogger)
     noSessionsDefined = len(parent.SessionProfiles.x2goprofs) == 0
     moreSessionsDefined = len(parent.SessionProfiles.x2goprofs) > 1
+    if parent.args.password and parent.SessionProfiles.current_profile:
+        parent.SessionProfiles.current_profile.setPassword(parent.args.password)
 
     #checkArgs(parent, parent.args, SessionProfiles)
     parent.logger('parent.SessionProfiles %s' % parent.SessionProfiles, x2go.loglevel_INFO, )
@@ -665,11 +697,11 @@ def startX2Go(parent):
         X2GoResumeSessions(parent, sessionsSuspended)
     else:
         if parent.args.minimized:
-            parent.logger('Start minimized', x2go.loglevel_INFO, )
+            parent.logger('Start X2GoChooseSessionScrn minimized', x2go.loglevel_INFO, )
             ChoiceScrn = X2GoChooseSessionScrn(parent, Iconize=True)
         else:
             if not noSessionsDefined and (not moreSessionsDefined or parent.SessionProfiles.defaultAvailable()):
-                parent.logger('Start password entry normally', x2go.loglevel_INFO, )
+                parent.logger('Start X2GoChooseSessionScrn entry normally with a default or chosen profile', x2go.loglevel_INFO, )
                 ChoiceScrn = X2GoChooseSessionScrn(parent, Iconize=True)
             elif noSessionsDefined:
                 parent.logger('Start Profile Definition', x2go.loglevel_INFO, )


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