[Python-Dev] subprocess insufficiently platform-independent? (original) (raw)
Steven Bethard steven.bethard at gmail.com
Mon Aug 25 19:39:22 CEST 2008
- Previous message: [Python-Dev] subprocess insufficiently platform-independent?
- Next message: [Python-Dev] subprocess insufficiently platform-independent?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, Aug 25, 2008 at 11:30 AM, Barry Warsaw <barry at python.org> wrote:
On Aug 25, 2008, at 1:13 PM, Guido van Rossum wrote:
Several people at Google seem to have independently discovered that despite all of the platform-independent goodness in subprocess.py, you still need to be platform aware. One of my colleagues summarized it like this:
""" Given a straightforward command list like: cmd = 'svn', 'ls', '[http://rietveld.googlecode.com/svn/trunk'] You apparently cannot pass this list to any subprocess function (subprocess.call() or otherwise) with a set of arguments that allow it to "just work" on both Windows and non-Windows systems. Unless I'm misremembering (I no longer have access to Windows), I believe that if you use ' '.join(cmd) as the first argument, it will work cross-platform.
FWIW, I've also struggled with similar issues. For example, with no shell= argument, Windows typically opens up an extra window to run the command, while Unix doesn't. My most recent hack around this looked something like::
try:
import win32con
except ImportError:
win32con = None
kwargs = dict(...)
if win32con is not None:
kwargs['creationflags'] = win32con.CREATE_NO_WINDOW
subprocess.Popen(cmd, **kwargs)
I'd love to see subprocess become more consistent cross-platform.
Steve
I'm not in-sane. Indeed, I am so far out of sane that you appear a tiny blip on the distant coast of sanity. --- Bucky Katt, Get Fuzzy
- Previous message: [Python-Dev] subprocess insufficiently platform-independent?
- Next message: [Python-Dev] subprocess insufficiently platform-independent?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]