From: <ef...@us...> - 2011-02-08 04:42:23
|
Revision: 8958 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8958&view=rev Author: efiring Date: 2011-02-08 04:42:17 +0000 (Tue, 08 Feb 2011) Log Message: ----------- cbook.report_memory: restore compatibility with earlier subprocess versions Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/cbook.py Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2011-02-07 22:49:09 UTC (rev 8957) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2011-02-08 04:42:17 UTC (rev 8958) @@ -1233,7 +1233,7 @@ def report_memory(i=0): # argument may go away 'return the memory consumed by process' - from subprocess import Popen, PIPE, check_output + from subprocess import Popen, PIPE pid = os.getpid() if sys.platform=='sunos5': a2 = Popen('ps -p %d -o osz' % pid, shell=True, @@ -1248,7 +1248,13 @@ stdout=PIPE).stdout.readlines() mem = int(a2[1].split()[0]) elif sys.platform.startswith('win'): - a2 = check_output(["tasklist", "/nh", "/fi", "pid eq %d" % pid]) + try: + a2 = Popen(["tasklist", "/nh", "/fi", "pid eq %d" % pid], + stdout=PIPE).stdout.read() + except OSError: + raise NotImplementedError( + "report_memory works on Windows only if " + "the 'tasklist' program is found") mem = int(a2.strip().split()[-2].replace(',','')) else: raise NotImplementedError( This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |