Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ea342b6

Browse filesBrowse files
committed
cbook.report_memory: If ps not found, raises NotImplementedError, not OSError.
1 parent a117e19 commit ea342b6
Copy full SHA for ea342b6

File tree

Expand file treeCollapse file tree

1 file changed

+21
-6
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+21
-6
lines changed

‎lib/matplotlib/cbook.py

Copy file name to clipboardExpand all lines: lib/matplotlib/cbook.py
+21-6Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.