[X2go-Commits] python-x2go.git - master (branch) updated: 0.1.1.4-112-g30887ea

X2go dev team git-admin at x2go.org
Thu Feb 23 23:04:00 CET 2012


The branch, master has been updated
       via  30887eac5d754a14b9baab46d8d42b10f402b612 (commit)
       via  84683b883de5c853506c116d715f8c054de4a2bf (commit)
      from  5aa1c6f22f593c1efb58c1f0342746f5772ea540 (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 -----------------------------------------------------------------
commit 30887eac5d754a14b9baab46d8d42b10f402b612
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Thu Feb 23 23:03:51 2012 +0100

    fix undefined names in terminal backend

commit 84683b883de5c853506c116d715f8c054de4a2bf
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Thu Feb 23 23:03:22 2012 +0100

    Provide hook methods for SSHFS failures (local folder sharing, printing, MIME box).

-----------------------------------------------------------------------

Summary of changes:
 debian/changelog                  |    2 +
 x2go/backends/terminal/_stdout.py |   14 ++++----
 x2go/client.py                    |   48 ++++++++++++++++++++++++++
 x2go/session.py                   |   68 ++++++++++++++++++++++++++++++++-----
 4 files changed, 116 insertions(+), 16 deletions(-)

The diff of changes is:
diff --git a/debian/changelog b/debian/changelog
index b74c497..f60caf1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -25,6 +25,8 @@ python-x2go (0.1.2.0-0~x2go1) UNRELEASED; urgency=low
     - Fix X2Go desktop sharing support.
     - New feature, allow/fix sessions on localhost system.
     - Tolerate names containing "-" characters.
+    - Provide hook methods for SSHFS failures (local folder sharing, printing,
+      MIME box).
   * Depend on python-xlib.
 
  -- Mike Gabriel <mike.gabriel at das-netzwerkteam.de>  Sat, 28 Sep 2012 01:44:21 +0100
diff --git a/x2go/backends/terminal/_stdout.py b/x2go/backends/terminal/_stdout.py
index 4af12c9..cb190ed 100644
--- a/x2go/backends/terminal/_stdout.py
+++ b/x2go/backends/terminal/_stdout.py
@@ -1115,22 +1115,22 @@ class X2goTerminalSessionSTDOUT(object):
         for stdout_line in stdout.read():
             try:
                 _new_value = stdout_line.split("=")[1].strip()
-                if 'gr_port=' in stdout_line and _new_value != str(session_info.graphics_port):
+                if 'gr_port=' in stdout_line and _new_value != str(self.session_info.graphics_port):
                     try:
-                        session_info.graphics_port = int(_new_value)
+                        self.session_info.graphics_port = int(_new_value)
                         self.logger('re-allocating graphics port for session %s, old server-side port is in use; new graphics port is %s' % (self.session_info, self.session_info.graphics_port), loglevel=log.loglevel_NOTICE)
                     except TypeError:
                         # if the re-allocation fails, this is fatal!!!
-                        raise X2goTerminalSessionException('Failed to retrieve new graphics port from server. X2Go Session cannot be resumed.')
-                elif 'sound_port=' in stdout_line and _new_value != str(session_info.snd_port):
+                        raise x2go_exceptions.X2goTerminalSessionException('Failed to retrieve new graphics port from server. X2Go Session cannot be resumed.')
+                elif 'sound_port=' in stdout_line and _new_value != str(self.session_info.snd_port):
                     try:
-                        session_info.snd_port = int(_new_value)
+                        self.session_info.snd_port = int(_new_value)
                         self.logger('re-allocating sound port for session %s, old server-side port is in use; new sound port is %s' % (self.session_info, self.session_info.snd_port), loglevel=log.loglevel_NOTICE)
                     except TypeError:
                         self.logger('Failed to retrieve new sound port from server for session %s, session will be without sound.' % self.session_info, loglevel=log.loglevel_WARN)
-                elif 'fs_port=' in stdout_line and _new_value != str(session_info.sshfs_port):
+                elif 'fs_port=' in stdout_line and _new_value != str(self.session_info.sshfs_port):
                     try:
-                        session_info.sshfs_port = int(_new_value)
+                        self.session_info.sshfs_port = int(_new_value)
                         self.logger('re-allocating sshfs port for session %s, old server-side port is in use; new sshfs port is %s' % (self.session_info, self.session_info.sshfs_port), loglevel=log.loglevel_NOTICE)
                     except TypeError:
                         self.logger('Failed to retrieve new sshfs port from server for session %s, session will be without client-side folder sharing. Neither will there be X2Go printing nor X2Go MIME box support.' % self.session_info, loglevel=log.loglevel_WARN)
diff --git a/x2go/client.py b/x2go/client.py
index 880c79d..85481fb 100644
--- a/x2go/client.py
+++ b/x2go/client.py
@@ -595,6 +595,54 @@ class X2goClient(object):
         """
         self.logger('HOOK_on_session_has_terminated (session_uuid: %s, profile_name: %s): session %s has terminated' % (session_uuid, profile_name, session_name), loglevel=log.loglevel_NOTICE)
 
+    def HOOK_printing_not_available(self, profile_name='UNKNOWN', session_name='UNKNOWN'):
+        """\
+        HOOK method: called if X2Go client-side printing is not available.
+
+        @param profile_name: profile name of session that called this hook method
+        @type profile_name: C{str}
+        @param session_name: X2Go session name
+        @type session_name: C{str}
+
+        """
+        self.logger('HOOK_foldersharing_not_available: X2Go\'s client-side printing feature is not available with this session (%s) of profile %s.' % (session_name, profile_name), loglevel=log.loglevel_WARN)
+
+    def HOOK_mimebox_not_available(self, profile_name='UNKNOWN', session_name='UNKNOWN'):
+        """\
+        HOOK method: called if the X2Go MIME box is not available.
+
+        @param profile_name: profile name of session that called this hook method
+        @type profile_name: C{str}
+        @param session_name: X2Go session name
+        @type session_name: C{str}
+
+        """
+        self.logger('HOOK_mimebox_not_available: X2Go\'s MIME box feature is not available with this session (%s) of profile %s.' % (session_name, profile_name), loglevel=log.loglevel_WARN)
+
+    def HOOK_foldersharing_not_available(self, profile_name='UNKNOWN', session_name='UNKNOWN'):
+        """\
+        HOOK method: called if X2Go client-side folder-sharing is not available.
+
+        @param profile_name: profile name of session that called this hook method
+        @type profile_name: C{str}
+        @param session_name: X2Go session name
+        @type session_name: C{str}
+
+        """
+        self.logger('HOOK_foldersharing_not_available: X2Go\'s client-side folder sharing feature is not available with this session (%s) of profile %s.' % (session_name, profile_name), loglevel=log.loglevel_WARN)
+
+    def HOOK_sshfs_not_available(self, profile_name='UNKNOWN', session_name='UNKNOWN'):
+        """\
+        HOOK method: called if the X2Go server denies SSHFS access.
+
+        @param profile_name: profile name of session that called this hook method
+        @type profile_name: C{str}
+        @param session_name: X2Go session name
+        @type session_name: C{str}
+
+        """
+        self.logger('HOOK_sshfs_not_available: the remote X2Go server (%s) denies SSHFS access for session %s. This will result in client-side folder sharing, printing and the MIME box feature being unavailable' % (session_name, profile_name), loglevel=log.loglevel_WARN)
+
     def _detect_backend_classes(self):
         # CONTROL session backend
         if type(self.control_backend) is types.StringType:
diff --git a/x2go/session.py b/x2go/session.py
index 5d58b63..c4b71b5 100644
--- a/x2go/session.py
+++ b/x2go/session.py
@@ -324,6 +324,46 @@ class X2goSession(object):
         # get rid of the faulty session...
         self.terminate()
 
+    def HOOK_printing_not_available(self):
+        """\
+        HOOK method: called if X2Go client-side printing is not available.
+
+        """
+        if self.client_instance:
+            self.client_instance.HOOK_printing_not_available(profile_name=self.profile_name, session_name=self.session_name)
+        else:
+            self.logger('HOOK_foldersharing_not_available: X2Go\'s client-side printing feature is not available with this session (%s) of profile %s.' % (self.session_name, self.profile_name), loglevel=log.loglevel_WARN)
+
+    def HOOK_mimebox_not_available(self):
+        """\
+        HOOK method: called if the X2Go MIME box is not available.
+
+        """
+        if self.client_instance:
+            self.client_instance.HOOK_mimebox_not_available(profile_name=self.profile_name, session_name=self.session_name)
+        else:
+            self.logger('HOOK_mimebox_not_available: X2Go\'s MIME box feature is not available with this session (%s) of profile %s.' % (self.session_name, self.profile_name), loglevel=log.loglevel_WARN)
+
+    def HOOK_foldersharing_not_available(self):
+        """\
+        HOOK method: called if X2Go client-side folder-sharing is not available.
+
+        """
+        if self.client_instance:
+            self.client_instance.HOOK_foldersharing_not_available(profile_name=self.profile_name, session_name=self.session_name)
+        else:
+            self.logger('HOOK_foldersharing_not_available: X2Go\'s client-side folder sharing feature is not available with this session (%s) of profile %s.' % (self.session_name, self.profile_name), loglevel=log.loglevel_WARN)
+
+    def HOOK_sshfs_not_available(self):
+        """\
+        HOOK method: called if the X2Go server denies SSHFS access.
+
+        """
+        if self.client_instance:
+            self.client_instance.HOOK_foldersharing_not_available(profile_name=self.profile_name, session_name=self.session_name)
+        else:
+            self.logger('HOOK_sshfs_not_available: the remote X2Go server (%s) denies SSHFS access for session %s. This will result in client-side folder sharing, printing and the MIME box feature being unavailable' % (self.profile_name, self.session_name), loglevel=log.loglevel_WARN)
+
     def HOOK_check_host_dialog(self, host, port, fingerprint='no fingerprint', fingerprint_type='RSA'):
         """\
         HOOK method: called if a host check is requested. This hook has to either return C{True} (default) or C{False}.
@@ -1164,7 +1204,7 @@ class X2goSession(object):
                         self.terminal_session and not self.faulty and self.terminal_session.start_sshfs()
                 except x2go_exceptions.X2goUserException, e:
                     self.logger('%s' % str(e), loglevel=log.loglevel_WARN)
-                    # TODO: handle this exception as a notification hook method...
+                    self.HOOK_sshfs_not_available()
                     self._SUPPORTED_PRINTING = False
                     self._SUPPORTED_MIMEBOX = False
                     self._SUPPORTED_FOLDERSHARING = False
@@ -1175,17 +1215,27 @@ class X2goSession(object):
                         self.terminal_session and not self.faulty and self.session_environment.update({'X2GO_SPOOLDIR': self.terminal_session.get_printing_spooldir(), })
                 except x2go_exceptions.X2goUserException, e:
                     self.logger('%s' % str(e), loglevel=log.loglevel_WARN)
-                    # TODO: handle this exception as a notification hook method...
+                    self.HOOK_printing_not_available()
                     self._SUPPORTED_PRINTING = False
 
-                if self._SUPPORTED_MIMEBOX and self.allow_mimebox:
-                    self.terminal_session and not self.faulty and self.terminal_session.start_mimebox(mimebox_extensions=self.mimebox_extensions, mimebox_action=self.mimebox_action)
-                    self.terminal_session and self.session_environment.update({'X2GO_MIMEBOX': self.terminal_session.get_mimebox_spooldir(), })
+                try:
+                    if self._SUPPORTED_MIMEBOX and self.allow_mimebox:
+                        self.terminal_session and not self.faulty and self.terminal_session.start_mimebox(mimebox_extensions=self.mimebox_extensions, mimebox_action=self.mimebox_action)
+                        self.terminal_session and self.session_environment.update({'X2GO_MIMEBOX': self.terminal_session.get_mimebox_spooldir(), })
+                except x2go_exceptions.X2goUserException, e:
+                    self.logger('%s' % str(e), loglevel=log.loglevel_WARN)
+                    self.HOOK_mimebox_not_available()
+                    self._SUPPORTED_MIMEBOX = False
 
-                if self.share_local_folders and self.terminal_session and not self.faulty and self.is_folder_sharing_available():
-                    if _control.get_transport().reverse_tunnels[self.terminal_session.get_session_name()]['sshfs'][1] is not None:
-                        for _folder in self.share_local_folders:
-                            self.share_local_folder(_folder)
+                try:
+                    if self.share_local_folders and self.terminal_session and not self.faulty and self.is_folder_sharing_available():
+                        if _control.get_transport().reverse_tunnels[self.terminal_session.get_session_name()]['sshfs'][1] is not None:
+                            for _folder in self.share_local_folders:
+                                self.share_local_folder(_folder)
+                except x2go_exceptions.X2goUserException, e:
+                    self.logger('%s' % str(e), loglevel=log.loglevel_WARN)
+                    self.HOOK_foldersharing_not_available()
+                    self._SUPPORTED_FOLDERSHARING = False
 
                 self.virgin = False
                 self.suspended = False


hooks/post-receive
-- 
python-x2go.git (Python X2Go Client API)

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 "python-x2go.git" (Python X2Go Client API).




More information about the x2go-commits mailing list