[X2Go-Commits] [python-x2go] 01/07: Create a "session.window" file in the session directory. This file for now contains one line "ID:<window-id>". The file appears once a session window comes up (start/resume), and disappears once the session window closes (suspend/terminate).

git-admin at x2go.org git-admin at x2go.org
Wed Jun 25 01:30:11 CEST 2014


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository python-x2go.

commit ce50d23f4fbb58381cf722b95c8afa4d4c772ae0
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Tue Jun 24 16:09:06 2014 +0200

    Create a "session.window" file in the session directory. This file for now contains one line "ID:<window-id>". The file appears once a session window comes up (start/resume), and disappears once the session window closes (suspend/terminate).
---
 debian/changelog                |    4 ++++
 x2go/backends/terminal/plain.py |   28 ++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index ed786a6..afe54ec 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -64,6 +64,10 @@ python-x2go (0.5.0.0-0x2go1) UNRELEASED; urgency=low
       (Fixes: #358).
     - Make sure that the x2gosuspend-session/x2goterminate-session commands
       are sent to the X2Go Server before we take down the NX proxy subprocess.
+    - Create a "session.window" file in the session directory. This file for now
+      contains one line "ID:<window-id>". The file appears once a session window
+      comes up (start/resume), and disappears once the session window closes
+      (suspend/terminate).
   * debian/control:
     + Add dependencies: python-requests, python-simplejson.
   * python-x2go.spec:
diff --git a/x2go/backends/terminal/plain.py b/x2go/backends/terminal/plain.py
index 67fb650..1b0b1e5 100644
--- a/x2go/backends/terminal/plain.py
+++ b/x2go/backends/terminal/plain.py
@@ -426,6 +426,8 @@ class X2GoTerminalSession(object):
         """
         self.release_telekinesis()
         self.release_proxy()
+        self.session_window = None
+        self.update_session_window_file()
 
         try:
 
@@ -1091,10 +1093,36 @@ class X2GoTerminalSession(object):
                 else:
                     self.logger('Session window ID for session %s is: %s' % (self.session_info.name, window.id), loglevel=log.loglevel_DEBUG)
                 self.session_window = window
+
+                self.update_session_window_file()
                 break
 
             gevent.sleep(1)
 
+    def update_session_window_file(self):
+        """\
+        Create a file that contains information on the session window.
+        .
+        If the file already exists, its content gets update.
+
+        """
+        session_window_file = os.path.join(self.session_info.local_container, 'session.window')
+        if self.session_window is not None:
+            f = open(session_window_file,'w')
+            if _X2GOCLIENT_OS != "Windows":
+                _id = self.session_window.id
+            else:
+                _id = self.session_window
+            f.write('ID:{window_id}\n'.format(window_id=_id))
+            f.close()
+            self.logger('Updating session.window file %s: Window-ID->%s' % (session_window_file, _id), loglevel=log.loglevel_DEBUG)
+        else:
+            try:
+                os.remove(session_window_file)
+            except OSError,e:
+                # this is no error in most cases...
+                self.logger('Failed to remove session.window file %s with error: %s' % (session_window_file, str(e)), loglevel=log.loglevel_INFO)
+
     def set_session_window_title(self, title, timeout=60):
         """\
         Modify the session window title.

--
Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/python-x2go.git


More information about the x2go-commits mailing list