Re: Call For Help! I need Windows/Python developers!

James Abbatiello <[email protected]> Fri, 26 Jun 2009 14:44:15 -0400
Newsgroups gmane.comp.python.cheetah
Message-ID <[email protected]>
On Fri, Jun 26, 2009 at 3:17 AM, R. Tyler Ballance<[email protected]> wrote:
> After Hudson found the 2.3 compat issue I switched this to use
> popen2.Popen4 as we discussed on IRC, seems to be working fine now (see
> build 88: http://hudson.cheetahtemplate.org/job/Cheetah%20(next)/88/)
>
> Please let me know if this works properly on Windows. (it's committed
> and pushed, attaching the patch for good measure)

Unfortunately it does not.  I missed the note in the manual but it
says popen2.Popen4 is not available on Windows.  I've changed it to
use os.popen4 which is available.  Patch attached.


>> 4) After running `setup.py install` there's no command-line "cheetah"
>> command installed.  The tests that try to shell out and run this
>> command don't work.  I've made a batch file and put it on my PATH to
>> work around this for now but I don't know what the proper long-term
>> solution is.  Use setuptools to create a wrapper .exe?
>> A patch addressing 1 through 3 is attached.
>
> setuptools currently knows enought to create a windows installer, what
> might be worth creating is a .bat file which will jumpstart cheetah
> (instead of a .exe)?
>
> I'm not too Windows savvy at the moment, but I'm certainly down for the
> cause ;)

A batch file is certainly possible.  The one I'm using right now uses
NT-specific syntax to be able to find python.exe and "cheetah" (the
small Python script).  I think the reason that setuptools makes .exe
files is probably for compatibility with Win9x.  All the .exe file
does is find the proper python.exe and launches it with the name of a
stub python script that does the proper thing.  I'll try finding some
docs on this to see how it is configured.

-- 
James Abbatiello

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

_______________________________________________
Cheetahtemplate-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
0001-Use-os.popen4-instead-of-popen2.Popen4-for-Windows-c.patch (application/octet-stream, 2.7 KB)
From 0e29f3afd51715b81a45be61e1a4b2e610f43209 Mon Sep 17 00:00:00 2001
From: James Abbatiello <[email protected]>
Date: Fri, 26 Jun 2009 14:36:11 -0400
Subject: [PATCH] Use os.popen4 instead of popen2.Popen4 for Windows compatibility

---
 src/Tests/CheetahWrapper.py |   35 ++++++++++-------------------------
 1 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/Tests/CheetahWrapper.py b/src/Tests/CheetahWrapper.py
index dd58834..11b903f 100644
--- a/src/Tests/CheetahWrapper.py
+++ b/src/Tests/CheetahWrapper.py
@@ -12,7 +12,6 @@ Besides unittest usage, recognizes the following command-line options:
         Show the output of each subcommand.  (Normally suppressed.)
 '''
 import os, shutil, sys, tempfile
-import popen2
 import unittest_local_copy as unittest
 
 import re                                     # Used by listTests.
@@ -150,17 +149,12 @@ Found %(result)r"""
                   test.
            out: None.
         """
-        proc = popen2.Popen4(cmd)
-        status = proc.wait()
-        output = proc.fromchild.read()
-        proc.fromchild.close()
-
-        if status >= 0:
-            status = status
-            signal = 0
-        else:
+        proc_stdin, proc_stdout = os.popen4(cmd)
+        proc_stdin.close()
+        output = proc_stdout.read()
+        status = proc_stdout.close()
+        if status == None:
             status = 0
-            signal = -status
         if OUTPUT:
             if output.endswith("\n"):
                 output = output[:-1]
@@ -168,8 +162,6 @@ Found %(result)r"""
             print "SUBCOMMAND:", cmd
             print output
             print
-        msg = "subcommand killed by signal %d: %s" % (signal, cmd)
-        self.failUnlessEqual(signal, 0, msg)
         msg = "subcommand exit status %d: %s" % (status, cmd)
         if status!=expectedStatus:
             print output
@@ -187,19 +179,12 @@ Found %(result)r"""
            in : cmd, string, the command to run.
            out: None.
         """
-        proc = popen2.Popen4(cmd)
-        status = proc.wait()
-        output = proc.fromchild.read()
-        proc.fromchild.close()
-
-        if status >= 0:
-            status = status
-            signal = 0
-        else:
+        proc_stdin, proc_stdout = os.popen4(cmd)
+        proc_stdin.close()
+        output = proc_stdout.read()
+        status = proc_stdout.close()
+        if status == None:
             status = 0
-            signal = -status
-        msg = "subcommand killed by signal %s: %s" % (signal, cmd)
-        self.failUnlessEqual(signal, 0, msg) # Signal must be 0.
         msg = "subcommand exit status %s: %s" % (status, cmd)
         self.failIfEqual(status, 0, msg) # Status must *not* be 0.
         if OUTPUT:
-- 
1.6.3.2.1299.gee46c