diff --git a/twander.py b/twander.py index d40e0bf..9fa3597 100755 --- a/twander.py +++ b/twander.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "twander" -RCSID = "$Id: twander.py,v 3.166 2005/01/24 20:33:19 tundra Exp $" +RCSID = "$Id: twander.py,v 3.167 2005/01/24 23:53:24 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -22,7 +22,6 @@ # Imports # #----------------------------------------------------------# -from commands import getstatusoutput import getopt import mutex import os @@ -861,6 +860,37 @@ ##### +# Run A Command, Returning Status And Output +# This Version Runs On Win32 Unlike commands.getstatusoutput() +##### + +def GetStatusOutput(command): + + # Handle Windows variants + + if sys.platform == 'win32': + pipe = os.popen(command, 'r') + + # Handle Unix variants + + else: + pipe = os.popen('{ ' + command + '; } 2>&1', 'r') + + output = pipe.read() + status = pipe.close() + + if status == None: + status = 0 + + if output[-1] == '\n': + output = output[:-1] + + return status, output + +# End of 'GetStatusOutput()' + + +##### # Build List Of Win32 Drives ##### @@ -4283,13 +4313,11 @@ stripnl = True vbl = vbl[1:] - results = getstatusoutput(vbl) + status, result = GetStatusOutput(vbl) # Replace with results if there was no error - if not results[0]: - - result = results[1] + if not status: # Strip newlines if asked to if stripnl: