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

x2go pushed a commit to annotated tag 0.2.0.3
in repository x2goclient.

commit 844198f8829e6d23d69ffa9bc092ca560ab73c35
Author: Mike Gabriel <mike.gabr...@das-netzwerkteam.de>
Date:   Wed Apr 11 10:04:43 2012 +0200

    Add code to redirect stdout and stderr when frozen with py2exe.
---
 debian/changelog |  1 +
 pyhoca-cli       | 41 +++++++++++++++++++++++++++++++++++++++--
 2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index db59077d..b4461ba0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,7 @@ pyhoca-cli (0.1.4.3-0~x2go1) UNRELEASED; urgency=low
 
   * New upstream version (0.1.4.3):
     - Replace non-code strings ,,X2go'' by ,,X2Go''.
+    - Add code to redirect stdout and stderr when frozen with py2exe.
   * Add python-suport (>=0.90) as dependency. Fix project name in control
     file.
   * Add proper license to copyright file.
diff --git a/pyhoca-cli b/pyhoca-cli
index a21fe0a0..cd7f62d2 100755
--- a/pyhoca-cli
+++ b/pyhoca-cli
@@ -30,13 +30,50 @@ import x2go
 
 import sys
 import os
+
+import sys
+import os
+
+PROG_NAME = os.path.basename(sys.argv[0]).replace('.exe', '')
+PROG_PID  = os.getpid()
+
+if hasattr(sys, 'frozen') and sys.frozen in ("windows_exe", "console_exe"):
+    class Win32_Logging(object):
+
+        softspace = 0
+        _fname = os.path.join(os.environ['AppData'], PROG_NAME, '%s.log' % 
PROG_NAME)
+        _file = None
+
+        def __init__(self, filemode='a'):
+            self._filemode = filemode
+
+        def write(self, text, **kwargs):
+            if self._file is None:
+                try:
+                    try:
+                        os.mkdir(os.path.dirname(self._fname))
+                    except:
+                        pass
+                    self._file = open(self._fname, self._filemode)
+                except:
+                    pass
+            else:
+                self._file.write(text)
+                self._file.flush()
+
+        def flush(self):
+            if self._file is not None:
+                self._file.flush()
+
+    sys.stdout = Win32_Logging(filemode='w+')
+    sys.stderr = Win32_Logging(filemode='a')
+    del Win32_Logging
+
 app = sys.argv[0]
 if app.startswith('./'):
     sys.path.insert(0, os.path.join(os.path.dirname(__file__)))
     os.environ['PYTHONX2GO_LOCAL'] = '1'
 
-PROG_NAME = os.path.basename(sys.argv[0])
-PROG_PID  = os.getpid()
 PROG_OPTIONS = sys.argv[1:]
 try:
     _password_index = PROG_OPTIONS.index('--password')+1

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on 
/srv/git/code.x2go.org/x2goclient.git
_______________________________________________
x2go-commits mailing list
x2go-commits@lists.x2go.org
https://lists.x2go.org/listinfo/x2go-commits

Reply via email to