@@ -1214,16 +1214,31 @@ def report_memory(i=0): # argument may go away
1214
1214
from matplotlib .subprocess_fixed import Popen , PIPE
1215
1215
pid = os .getpid ()
1216
1216
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" )
1219
1224
mem = int (a2 [- 1 ].strip ())
1220
1225
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" )
1223
1233
mem = int (a2 [1 ].split ()[1 ])
1224
1234
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" )
1227
1242
mem = int (a2 [1 ].split ()[0 ])
1228
1243
elif sys .platform .startswith ('win' ):
1229
1244
try :
0 commit comments