*** commands.py Tue Feb 3 22:52:43 2004 --- commands.py.orig Tue Feb 3 22:42:00 2004 *************** *** 19,30 **** [Note: it would be nice to add functions to interpret the exit status.] """ ! import sys ! ! if sys.platform == "win32": ! __all__ = ["getstatusoutput","getoutput"] ! else: ! __all__ = ["getstatusoutput","getoutput","getstatus"] # Module 'commands' # --- 19,25 ---- [Note: it would be nice to add functions to interpret the exit status.] """ ! __all__ = ["getstatusoutput","getoutput","getstatus"] # Module 'commands' # *************** *** 35,44 **** # Get 'ls -l' status for an object into a string # ! if sys.platform != "win32": ! def getstatus(file): ! """Return output of "ls -ld " in a string.""" ! return getoutput('ls -ld' + mkarg(file)) # Get the output from a shell command into a string. # The exit status is ignored; a trailing newline is stripped. --- 30,39 ---- # Get 'ls -l' status for an object into a string # ! def getstatus(file): ! """Return output of "ls -ld " in a string.""" ! return getoutput('ls -ld' + mkarg(file)) ! # Get the output from a shell command into a string. # The exit status is ignored; a trailing newline is stripped. *************** *** 55,64 **** def getstatusoutput(cmd): """Return (status, output) of executing cmd in a shell.""" import os ! if sys.platform == "win32": ! pipe = os.popen("%s 2>&1" % cmd, "r") ! else: ! pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r') text = pipe.read() sts = pipe.close() if sts is None: sts = 0 --- 50,56 ---- def getstatusoutput(cmd): """Return (status, output) of executing cmd in a shell.""" import os ! pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r') text = pipe.read() sts = pipe.close() if sts is None: sts = 0