[Patches] [ python-Patches-660505 ] make commands.getstatusoutput work on windows

noreply@sourceforge.net noreply@sourceforge.net
Tue, 31 Dec 2002 12:24:40 -0800


Patches item #660505, was opened at 2002-12-31 12:24
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=660505&group_id=5470

Category: Library (Lib)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Aleksandar Totic (atotic)
Assigned to: Nobody/Anonymous (nobody)
Summary: make commands.getstatusoutput work on windows

Initial Comment:
The following patch makes commands.getstatusoutput 
work on windows NT. Original code:
pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r')

did not work on window's cmd.exe. This is because 
cmd.exe does not support "{}" command blocks.

To my knowledge, cmd.exe does not support command 
blocks at all. So the patch simply executes the 
command on nt, without any wrapping beyond adding 
redirection.

old code: (r 1.15)
pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r')

new code:
if (os.name == 'nt'):
    pipe = os.popen(cmd + ' 2>&1', 'r')
else:
    pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r')

this is CVS Python source on Dec 31st, 2002, running 
on Windows XP professional.

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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=660505&group_id=5470