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

"R. Tyler Ballance" <[email protected]> Fri, 26 Jun 2009 00:17:03 -0700
Newsgroups gmane.comp.python.cheetah
Message-ID <20090626071703.GB10139@starfruit>
Hey James, reply inline..

On Fri, 26 Jun 2009, James Abbatiello wrote:

> I've just compiled NameMapper under Windows.  There is only a minor
> change needed to _namemapper.c.  See attached patch.  I compiled this
> on Windows XP using Visual C++ 2008 Express (that's the free version).
>  The Python version is 2.6.2 installed from the python.org installer.
> 
> I've also tried to get the tests running under Windows.  There are a
> few problems here:
> 1) Use of commands.getstatusoutput().  This isn't supported on
> Windows.  I've replaced this will subprocess.Popen which seems to be
> the preferred new method.

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)
 

> 2) Some tests assume that the shell will expand globs ("*.tmpl") and
> the Windows shell doesn't do this.  I'm skipping these tests on
> Windows.

Your other patch fixes this nicely :)

> 3) One place assumed that temp files went in /tmp.  I fixed that to be
> more general.

Looks good to me

> 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 ;)


Cheers

-R. Tyler Ballance
Slide, Inc.

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

_______________________________________________
Cheetahtemplate-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
0001-Replace-subprocess-with-popen2-which-is-Python-2.3-c.patch (text/plain, 2.7 KB)
From 962ed4aeea25f70e85dadf9e425e8d364475348c Mon Sep 17 00:00:00 2001
From: R. Tyler Ballance <[email protected]>
Date: Fri, 26 Jun 2009 00:09:00 -0700
Subject: [PATCH] Replace subprocess with popen2, which is Python 2.3 compatible

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

diff --git a/src/Tests/CheetahWrapper.py b/src/Tests/CheetahWrapper.py
index 3e94964..dd58834 100644
--- a/src/Tests/CheetahWrapper.py
+++ b/src/Tests/CheetahWrapper.py
@@ -11,7 +11,8 @@ Besides unittest usage, recognizes the following command-line options:
      --output
         Show the output of each subcommand.  (Normally suppressed.)
 '''
-import subprocess, os, shutil, sys, tempfile
+import os, shutil, sys, tempfile
+import popen2
 import unittest_local_copy as unittest
 
 import re                                     # Used by listTests.
@@ -149,17 +150,17 @@ Found %(result)r"""
                   test.
            out: None.
         """
-        subproc = subprocess.Popen(cmd,
-                                   stdout=subprocess.PIPE,
-                                   stderr=subprocess.STDOUT,
-                                   shell=True)
-        output = subproc.communicate()[0]
-        if subproc.returncode >= 0:
-            status = subproc.returncode
+        proc = popen2.Popen4(cmd)
+        status = proc.wait()
+        output = proc.fromchild.read()
+        proc.fromchild.close()
+
+        if status >= 0:
+            status = status
             signal = 0
         else:
             status = 0
-            signal = -subproc.returncode
+            signal = -status
         if OUTPUT:
             if output.endswith("\n"):
                 output = output[:-1]
@@ -186,17 +187,17 @@ Found %(result)r"""
            in : cmd, string, the command to run.
            out: None.
         """
-        subproc = subprocess.Popen(cmd,
-                                   stdout=subprocess.PIPE,
-                                   stderr=subprocess.STDOUT,
-                                   shell=True)
-        output = subproc.communicate()[0]
-        if subproc.returncode >= 0:
-            status = subproc.returncode
+        proc = popen2.Popen4(cmd)
+        status = proc.wait()
+        output = proc.fromchild.read()
+        proc.fromchild.close()
+
+        if status >= 0:
+            status = status
             signal = 0
         else:
             status = 0
-            signal = -subproc.returncode
+            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)
-- 
1.6.3
signature.asc (application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)

iEYEARECAAYFAkpEde8ACgkQFCbH3D9R4W/EuACeIUYRDtz6ENwuF1drkZZFj9p1
OuAAn1gyPpScuHQyHHp+HSRstBvOpo8W
=iMmC
-----END PGP SIGNATURE-----