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

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


The branch, twofactorauth has been updated
       via  9268d9b3f569cc7870c0def623ee562394126abc (commit)
      from  6ccfa2bba51f226738e667d1d4115427520ce1a5 (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                    |    2 +-
 pyhoca/wxgui/frontend.py      |   20 ++++++++++----------
 pyhoca/wxgui/logon.py         |    9 ++++++---
 pyhoca/wxgui/menus_taskbar.py |    1 -
 pyhoca/wxgui/notify.py        |   42 ++++++++++++++++++++++++++++++++++++++---
 5 files changed, 56 insertions(+), 18 deletions(-)

The diff of changes is:
diff --git a/pyhoca-gui b/pyhoca-gui
index 2b1508f..61619c0 100755
--- a/pyhoca-gui
+++ b/pyhoca-gui
@@ -40,7 +40,7 @@ import exceptions
 app = sys.argv[0]
 if app.startswith('./'):
     sys.path.insert(0, os.path.join(os.path.dirname(__file__)))
-    os.environ['PYTHONX2GO_LOCAL'] = '1'
+    os.environ['PYHOCAGUI_LOCAL'] = '1'
 
 # Python X2go modules
 import x2go
diff --git a/pyhoca/wxgui/frontend.py b/pyhoca/wxgui/frontend.py
index bfbd4af..b43c706 100644
--- a/pyhoca/wxgui/frontend.py
+++ b/pyhoca/wxgui/frontend.py
@@ -179,9 +179,9 @@ class PyHocaGUI(wx.App, x2go.X2goClient):
 
         try:
             self._X2goClient__connect_session(session_uuid)
-            self.logger('auto-connected session profile %s' % self._X2goClient__get_session_profile_name(session_uuid), loglevel=x2go.log.loglevel_NOTICE)
+            self._pyhoca_logger('auto-connected session profile %s' % self._X2goClient__get_session_profile_name(session_uuid), loglevel=x2go.log.loglevel_NOTICE)
         except x2go.AuthenticationException:
-            self.logger('no pubkey authentication available for session profile %s' % self._X2goClient__get_session_profile_name(session_uuid), loglevel=x2go.log.loglevel_NOTICE)
+            self._pyhoca_logger('no pubkey authentication available for session profile %s' % self._X2goClient__get_session_profile_name(session_uuid), loglevel=x2go.log.loglevel_NOTICE)
 
     # wx.App's OnExit method
     def OnExit(self):
@@ -198,7 +198,7 @@ class PyHocaGUI(wx.App, x2go.X2goClient):
         STILL UNDOCUMENTED
 
         """
-        self._pyhoca_logger('Exit application', loglevel=x2go.log.loglevel_INFO, )
+        self._pyhoca_logger('exit application', loglevel=x2go.log.loglevel_INFO, )
         self.taskbar.Close()
         self.notifier.Close()
         self.Exit()
@@ -261,7 +261,7 @@ class PyHocaGUI(wx.App, x2go.X2goClient):
             _logon_window = logon.PyHocaGUI_DialogBoxPassword(self, self.current_profile_name, caller=self )
             self._sub_windows.append(_logon_window)
         if self._X2goClient__is_session_connected(session_uuid):
-            self.notifier.send('%s - connect' % self.current_profile_name, 'Public SSH key authentication has been successful.', timeout=4000)
+            self.notifier.send('%s - connect' % self.current_profile_name, 'Public SSH key authentication has been successful.', icon='auth_success', timeout=4000)
         else:
             self._pyhoca_logger('public SSH key authentication to server failed, trying next auth-mechanism', loglevel=x2go.log.loglevel_INFO, )
 
@@ -275,7 +275,7 @@ class PyHocaGUI(wx.App, x2go.X2goClient):
         _query_session = self._X2goClient__client_registered_sessions_of_name(self.current_profile_name)[0]
         session_uuid = self._X2goClient__register_session(profile_name=self.current_profile_name)
         gevent.spawn(self._X2goClient__start_session, session_uuid)
-        self.notifier.send(self.current_profile_name, 'New X2go session starting up...', timeout=10000)
+        self.notifier.send(self.current_profile_name, 'New X2go session starting up...', icon='session_start', timeout=10000)
 
 
     def OnSessionResume(self, evt):
@@ -288,7 +288,7 @@ class PyHocaGUI(wx.App, x2go.X2goClient):
         session_uuid = _control_session.get_uuid()
         session_name = self._eventid_sessionnames_map[evt.GetId()]
         gevent.spawn(self._X2goClient__resume_session, session_uuid, session_name=session_name)
-        self.notifier.send(self.current_profile_name, 'Resuming X2go session...\nSession: %s' % session_name, timeout=10000)
+        self.notifier.send(self.current_profile_name, 'Resuming X2go session...\nSession: %s' % session_name, icon='session_resume', timeout=10000)
         self._eventid_sessionnames_map = {}
 
     def OnSessionSuspend(self, evt):
@@ -303,7 +303,7 @@ class PyHocaGUI(wx.App, x2go.X2goClient):
         gevent.spawn(self._X2goClient__suspend_session, session_uuid, session_name=session_name)
         gevent.sleep(2)
         if self._X2goClient__is_session_suspended(session_uuid, session_name):
-            self.notifier.send(self.current_profile_name, 'X2go session has been suspended.\nSession: %s' % session_name, timeout=8000)
+            self.notifier.send(self.current_profile_name, 'X2go session has been suspended.\nSession: %s' % session_name, icon='session_suspend', timeout=8000)
 
         self._eventid_sessionnames_map = {}
 
@@ -319,7 +319,7 @@ class PyHocaGUI(wx.App, x2go.X2goClient):
         gevent.spawn(self._X2goClient__terminate_session, session_uuid, session_name=session_name)
         gevent.sleep(2)
         if self._X2goClient__has_session_terminated(session_uuid, session_name):
-            self.notifier.send(self.current_profile_name, 'X2go session has terminated.\nSession: %s' % session_name, timeout=8000)
+            self.notifier.send(self.current_profile_name, 'X2go session has terminated.\nSession: %s' % session_name, icon='session_terminate', timeout=8000)
 
         self._eventid_sessionnames_map = {}
 
@@ -336,7 +336,7 @@ class PyHocaGUI(wx.App, x2go.X2goClient):
             _notify_text = 'Cleaning X2go sessions...'
             for session_name in session_names:
                 _notify_text += '\nSession: %s' % session_name
-            self.notifier.send(self.current_profile_name, _notify_text, timeout=10000)
+            self.notifier.send(self.current_profile_name, _notify_text, icon='session_cleanall', timeout=10000)
         gevent.spawn(self._X2goClient__clean_sessions, session_uuid)
 
     def OnSessionDisconnect(self, evt):
@@ -352,7 +352,7 @@ class PyHocaGUI(wx.App, x2go.X2goClient):
         self._X2goClient__disconnect_session(session_uuid)
         gevent.sleep(2)
         if not self._X2goClient__is_session_connected(session_uuid):
-            self.notifier.send('%s - disconnect' % self.current_profile_name, 'X2go Profile is now disconnected.', timeout=4000)
+            self.notifier.send('%s - disconnect' % self.current_profile_name, 'X2go Profile is now disconnected.', icon='auth_disconnect', timeout=4000)
 
 
     def OnProfileAdd(self, evt):
diff --git a/pyhoca/wxgui/logon.py b/pyhoca/wxgui/logon.py
index e15e7a0..b78bc06 100644
--- a/pyhoca/wxgui/logon.py
+++ b/pyhoca/wxgui/logon.py
@@ -172,12 +172,15 @@ class PyHocaGUI_DialogBoxPassword(wx.Dialog):
             self._PyHocaGUI._X2goClient__connect_session(session_uuid, username=username, password=password, force_password_auth=True)
             self._PyHocaGUI._post_authenticate(evt, session_uuid)
             self._PyHocaGUI.notifier.prepare('AUTH_%s' % self.current_profile_name, 
-                                             title='%s - connect' % self.current_profile_name, 
-                                             text='Authentication has been successful.')
+                                             title='%s - connect' % self.current_profile_name,
+                                             text='Authentication has been successful.',
+                                             icon='auth_success')
+
         except x2go.AuthenticationException:
             self._PyHocaGUI.notifier.prepare('AUTH_%s' % self.current_profile_name, 
                                              title='%s - connect failure' % self.current_profile_name, 
-                                             text='Authentication failed!')
+                                             text='Authentication failed!',
+                                             icon='auth_failed')
 
         self._PyHocaGUI.notifier.send(self.current_profile_name, context='AUTH_%s' % self.current_profile_name, timeout=4000)
         self.Destroy()
diff --git a/pyhoca/wxgui/menus_taskbar.py b/pyhoca/wxgui/menus_taskbar.py
index d804944..1826b4a 100644
--- a/pyhoca/wxgui/menus_taskbar.py
+++ b/pyhoca/wxgui/menus_taskbar.py
@@ -47,7 +47,6 @@ class PyHocaGUI_Menu_TaskbarManageProfile(wx.Menu):
         self._PyHocaGUI._eventid_profilenames_map[ID_EDITPROFILE] = \
             self._PyHocaGUI._eventid_profilenames_map[ID_DELETEPROFILE] = profile_name
 
-        
         self.Append(text="Edit Profile", id=ID_EDITPROFILE)
         self.AppendSeparator()
         self.Append(text="Delete Profile", id=ID_DELETEPROFILE)
diff --git a/pyhoca/wxgui/notify.py b/pyhoca/wxgui/notify.py
index be92b3c..606a0d8 100644
--- a/pyhoca/wxgui/notify.py
+++ b/pyhoca/wxgui/notify.py
@@ -18,6 +18,7 @@
 # Free Software Foundation, Inc.,
 # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
+import os
 import wx, time, webbrowser
 import images
 from x2go import X2GOCLIENT_OS
@@ -26,13 +27,34 @@ if X2GOCLIENT_OS in ('Linux', 'Mac'):
     import pynotify
 import exceptions
 
+if os.environ['PYHOCAGUI_LOCAL'] == '1':
+    _icons_location = 'file://%s/icons' % os.path.abspath(os.path.curdir)
+else:
+    _icons_location = 'file:///usr/share/icons'
+
+
 class NotSupportedException(exceptions.StandardError): pass
 class PyHocaNotificationException(exceptions.StandardError): pass
 
 class libnotify_NotifierPopup(object):
 
+    icon_hash = { 'auth_success': 'gtk-ok',
+                  'auth_failed': 'dialog-warning',
+                  'auth_disconnect': 'gtk-close',
+                  'session_start': 'x2go-icons/32x32/x2go.png',
+                  'session_resume': 'x2go-icons/32x32/x2go.png',
+                  'session_suspend': '',
+                  'session_terminate': '',
+                  'session_cleanall': '',
+                  'profile_new': '',
+                  'profile_delete': '',
+                  'profile_edit': '',
+                  'profile_save': '',
+                }
+
     title = {}
     text = {}
+    icon = {}
 
     def __init__(self, _PyHocaGUI):
         self._PyHocaGUI = _PyHocaGUI
@@ -41,13 +63,15 @@ class libnotify_NotifierPopup(object):
         if not pynotify.init("PyHocaGUI"):
             raise NotSupportedException
 
-    def prepare(self, context, title=None, text=None):
+    def prepare(self, context, title=None, text=None, icon=None):
         if title is not None:
             self.title[context] = title
         if text is not None:
             self.text[context] = text
+        if icon is not None:
+            self.icon[context] = icon
 
-    def send(self, title=None, text=None, context=None, timeout=8000):
+    def send(self, title=None, text=None, context=None, icon=None, timeout=8000):
         if context is not None:
             try:
                 title = self.title[context]
@@ -59,8 +83,20 @@ class libnotify_NotifierPopup(object):
                 del self.text[context]
             except KeyError:
                 pass
+            try:
+                icon = self.icon[context]
+                del self.icon[context]
+            except KeyError:
+                pass
+
+        # translate our meta names for notification icons
+        if icon in self.icon_hash.keys():
+            icon = self.icon_hash[icon]
+
+        if icon and '/' in icon:
+            icon = '%s/%s' % (_icons_location, icon)
 
-        n = pynotify.Notification(title, text)
+        n = pynotify.Notification(title, text, icon)
         n.set_urgency(pynotify.URGENCY_NORMAL)
         n.set_timeout(timeout)
 


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