[X2go-Commits] python-x2go.git - release/0.1.1.x (branch) updated: 0.1.1.6-3-g47ed80c

X2go dev team git-admin at x2go.org
Thu Sep 15 00:15:33 CEST 2011


The branch, release/0.1.1.x has been updated
       via  47ed80c80e7d6e8388d699ed3e0897a4d7be9d04 (commit)
      from  6fd557ede24430dac8b67b2341152969ad5b1584 (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 47ed80c80e7d6e8388d699ed3e0897a4d7be9d04
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Thu Sep 15 00:13:56 2011 +0200

    Add support for x2goumount-session calls.

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

Summary of changes:
 debian/changelog                  |    2 +-
 x2go/backends/terminal/_stdout.py |   18 +++++++++++++++
 x2go/client.py                    |   42 +++++++++++++++++++++++++++++++++++++
 x2go/session.py                   |   36 ++++++++++++++++++++++++++++++-
 4 files changed, 96 insertions(+), 2 deletions(-)

The diff of changes is:
diff --git a/debian/changelog b/debian/changelog
index bcd22a1..9d3079e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,7 +1,7 @@
 python-x2go (0.1.1.7-0~x2go1) UNRELEASED; urgency=low
 
   * New upstream version (0.1.1.6), bugfix release for 0.1.1.x series:
-    - continue development...
+    - Add support for x2goumount-session calls.
 
  -- Mike Gabriel <mike.gabriel at das-netzwerkteam.de>  Wed, 14 Sep 2011 21:43:55 +0200
 
diff --git a/x2go/backends/terminal/_stdout.py b/x2go/backends/terminal/_stdout.py
index 92dac9f..339aa5f 100644
--- a/x2go/backends/terminal/_stdout.py
+++ b/x2go/backends/terminal/_stdout.py
@@ -678,6 +678,24 @@ class X2goTerminalSessionSTDOUT(object):
         (stdin, stdout, stderr) = self.control_session._x2go_exec_command(cmd_line)
         self.logger('x2gomountdirs output is : %s' % stdout.read().split('\n'), log.loglevel_NOTICE)
 
+    def unshare_all_local_folders(self):
+        """\
+        Unshare all local folders mount in the X2go session.
+
+        @return: returns C{True} if all local folders could be successfully unmounted from the X2go server session
+        @rtype: bool
+
+        """
+        self.logger('unsharing all local folders for session %s' % self.session_info, log.loglevel_INFO)
+
+        cmd_line = [ 'export HOSTNAME &&',
+                     'x2goumount-session', 
+                     self.session_info,
+                   ]
+
+        (stdin, stdout, stderr) = self.control_session._x2go_exec_command(cmd_line)
+        self.logger('x2goumount-session output is : %s' % stdout.read().split('\n'), log.loglevel_NOTICE)
+
     def color_depth(self):
         """\
         Retrieve the session's color depth.
diff --git a/x2go/client.py b/x2go/client.py
index 396757b..cd3bae3 100644
--- a/x2go/client.py
+++ b/x2go/client.py
@@ -1501,6 +1501,48 @@ class X2goClient(object):
             return False
     __share_local_folder_with_session = share_local_folder_with_session
 
+    def unshare_all_local_folders_from_session(self, session_uuid=None, folder_name=_LOCAL_HOME, profile_name=None):
+        """\
+        Unshare all local folders mounted in X2go session registered as
+        C{session_uuid}.
+
+        When calling this method all client-side mounted folders on the X2go 
+        server (via sshfs) for session with ID <session_uuid> will get
+        unmounted.
+
+        @param session_uuid: the X2go session's UUID registry hash
+        @type session_uuid: C{str}
+        @param profile_name: alternatively, the profile name can be used to unshare
+            mounted folders
+        @type profile_name: C{str}
+
+        @return: returns C{True} if all local folders could be successfully unmounted
+        @rtype: C{bool}
+
+        """
+        if session_uuid is None and profile_name:
+            _associated = self._X2goClient__client_associated_sessions_of_profile_name(profile_name, return_objects=False)
+            if len(_associated) > 0:
+                session_uuid = _associated[0]
+        if session_uuid:
+            return self.session_registry(session_uuid).unshare_all_local_folders()
+        else:
+            self.logger('Cannot find a terminal session for profile ,,%s\'\' from which to unmount local folders' % profile_name, loglevel=log.loglevel_WARN)
+            return False
+    __unshare_all_local_folders_from_session = unshare_all_local_folders_from_session
+
+    def session_get_shared_folders(self, session_uuid):
+        """\
+        Get a list of local folders mounted within X2go session with session hash <session_uuid>
+        from this client.
+
+        @return: returns a C{list} of those local folder names that are mounted within X2go session <session_uuid>.
+        @rtype: C{list}
+
+        """
+        return self(session_uuid).get_shared_folders()
+    __session_get_shared_folders = session_get_shared_folders
+
     ###
     ### Provide access to the X2goClient's session registry
     ### 
diff --git a/x2go/session.py b/x2go/session.py
index 7d1c95e..054cfa1 100644
--- a/x2go/session.py
+++ b/x2go/session.py
@@ -236,6 +236,7 @@ class X2goSession(object):
         self.terminal_params = {}
         self.sshproxy_params = {}
         self.update_params(params)
+        self.shared_folders = []
 
         self.session_environment = {}
 
@@ -1396,13 +1397,46 @@ class X2goSession(object):
         """
         if self.has_terminal_session():
             if self.allow_share_local_folders:
-                return self.terminal_session.share_local_folder(folder_name=folder_name)
+                if self.terminal_session.share_local_folder(folder_name=folder_name):
+                    self.shared_folders.append(folder_name)
+                    return True
+                return False
             else:
                 self.logger('local folder sharing is disabled for this session profile', loglevel=log.loglevel_WARN)
         else:
             raise X2goSessionException('this X2goSession object does not have any associated terminal')
     __share_local_folder = share_local_folder
 
+    def unshare_all_local_folders(self):
+        """\
+        Unshare all local folders mounted within this X2go session.
+
+        @return: returns C{True} if all local folders could be successfully unmounted
+            inside this X2go session
+        @rtype: C{bool}
+
+        """
+        if self.has_terminal_session():
+            if self.allow_share_local_folders:
+                self.shared_folders = []
+                return self.terminal_session.unshare_all_local_folders()
+            else:
+                self.logger('local folder sharing is disabled for this session profile', loglevel=log.loglevel_WARN)
+        else:
+            raise X2goSessionException('this X2goSession object does not have any associated terminal')
+    __unshare_all_local_folders = unshare_all_local_folders
+
+    def get_shared_folders(self):
+        """\
+        Get a list of local folders mounted within this X2go session from this client.
+
+        @return: returns a C{list} of those folder names that are mounted with this X2go session.
+        @rtype: C{list}
+
+        """
+        return self.shared_folders
+    __get_shared_folders = get_shared_folders
+
     def is_locked(self):
         """\
         Query session if it is locked by some command being processed.


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