@@ -1214,16 +1214,31 @@ def report_memory(i=0): # argument may go away
12141214 from matplotlib .subprocess_fixed import Popen , PIPE
12151215 pid = os .getpid ()
12161216 if sys .platform == 'sunos5' :
1217- a2 = Popen ('ps -p %d -o osz' % pid , shell = True ,
1218- stdout = PIPE ).stdout .readlines ()
1217+ try :
1218+ a2 = Popen ('ps -p %d -o osz' % pid , shell = True ,
1219+ stdout = PIPE ).stdout .readlines ()
1220+ except OSError :
1221+ raise NotImplementedError (
1222+ "report_memory works on Sun OS only if "
1223+ "the 'ps' program is found" )
12191224 mem = int (a2 [- 1 ].strip ())
12201225 elif sys .platform .startswith ('linux' ):
1221- a2 = Popen ('ps -p %d -o rss,sz' % pid , shell = True ,
1222- stdout = PIPE ).stdout .readlines ()
1226+ try :
1227+ a2 = Popen ('ps -p %d -o rss,sz' % pid , shell = True ,
1228+ stdout = PIPE ).stdout .readlines ()
1229+ except OSError :
1230+ raise NotImplementedError (
1231+ "report_memory works on Linux only if "
1232+ "the 'ps' program is found" )
12231233 mem = int (a2 [1 ].split ()[1 ])
12241234 elif sys .platform .startswith ('darwin' ):
1225- a2 = Popen ('ps -p %d -o rss,vsz' % pid , shell = True ,
1226- stdout = PIPE ).stdout .readlines ()
1235+ try :
1236+ a2 = Popen ('ps -p %d -o rss,vsz' % pid , shell = True ,
1237+ stdout = PIPE ).stdout .readlines ()
1238+ except OSError :
1239+ raise NotImplementedError (
1240+ "report_memory works on Mac OS only if "
1241+ "the 'ps' program is found" )
12271242 mem = int (a2 [1 ].split ()[0 ])
12281243 elif sys .platform .startswith ('win' ):
12291244 try :
0 commit comments