##// END OF EJS Templates
use popen in genutils.getoutput
vivainio -
Show More
@@ -5,7 +5,7 b' General purpose utilities.'
5 This is a grab-bag of stuff I find useful in most programs I write. Some of
5 This is a grab-bag of stuff I find useful in most programs I write. Some of
6 these things are also convenient when working at the command line.
6 these things are also convenient when working at the command line.
7
7
8 $Id: genutils.py 1126 2006-02-06 02:31:40Z fperez $"""
8 $Id: genutils.py 1139 2006-02-10 15:55:09Z vivainio $"""
9
9
10 #*****************************************************************************
10 #*****************************************************************************
11 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
11 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
@@ -375,11 +375,19 b" def getoutput(cmd,verbose=0,debug=0,header='',split=0):"
375 - split(0): if true, the output is returned as a list split on newlines.
375 - split(0): if true, the output is returned as a list split on newlines.
376
376
377 Note: a stateful version of this function is available through the
377 Note: a stateful version of this function is available through the
378 SystemExec class."""
378 SystemExec class.
379
380 This is pretty much deprecated and rarely used,
381 genutils.getoutputerror may be what you need.
382
383 """
379
384
380 if verbose or debug: print header+cmd
385 if verbose or debug: print header+cmd
381 if not debug:
386 if not debug:
382 output = commands.getoutput(cmd)
387 output = os.popen(cmd).read()
388 # stipping last \n is here for backwards compat.
389 if output.endswith('\n'):
390 output = output[:-1]
383 if split:
391 if split:
384 return output.split('\n')
392 return output.split('\n')
385 else:
393 else:
@@ -1,3 +1,7 b''
1 2006-02-10 Ville Vainio <vivainio@gmail.com>
2
3 * genutils.py: getoutput now works in win32 too
4
1 2006-02-09 Ville Vainio <vivainio@gmail.com>
5 2006-02-09 Ville Vainio <vivainio@gmail.com>
2
6
3 * test/*: Added a unit testing framework (finally).
7 * test/*: Added a unit testing framework (finally).
General Comments 0
You need to be logged in to leave comments. Login now