Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6cfc685

Browse files
committed
Fix EINTR problem in font_manager.py
svn path=/trunk/matplotlib/; revision=7953
1 parent 87097cf commit 6cfc685

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2009-11-12 font_manager.py should no longer cause EINTR on Python 2.6
2+
(but will on the 2.5 version of subprocess). Also the
3+
fc-list command in that file was fixed so now it should
4+
actually find the list of fontconfig fonts. - JKS
5+
16
2009-11-10 Single images, and all images in renderers with
27
option_image_nocomposite (i.e. agg, macosx and the svg
38
backend when rcParams['svg.image_noscale'] is True), are

lib/matplotlib/font_manager.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
see license/LICENSE_TTFQUERY.
4343
"""
4444

45-
import os, sys, glob
45+
import os, sys, glob, subprocess
4646
try:
4747
set
4848
except NameError:
@@ -292,16 +292,12 @@ def get_fontconfig_fonts(fontext='ttf'):
292292
grab all of the fonts the user wants to be made available to
293293
applications, without needing knowing where all of them reside.
294294
"""
295-
try:
296-
import commands
297-
except ImportError:
298-
return {}
299-
300295
fontext = get_fontext_synonyms(fontext)
301296

302297
fontfiles = {}
303-
status, output = commands.getstatusoutput("fc-list file")
304-
if status == 0:
298+
pipe = subprocess.Popen(['fc-list', '', 'file'], stdout=subprocess.PIPE)
299+
output = pipe.communicate()[0]
300+
if pipe.returncode == 0:
305301
for line in output.split('\n'):
306302
fname = line.split(':')[0]
307303
if (os.path.splitext(fname)[1][1:] in fontext and
@@ -1244,11 +1240,11 @@ def is_opentype_cff_font(filename):
12441240
import re
12451241

12461242
def fc_match(pattern, fontext):
1247-
import commands
12481243
fontexts = get_fontext_synonyms(fontext)
12491244
ext = "." + fontext
1250-
status, output = commands.getstatusoutput('fc-match -sv "%s"' % pattern)
1251-
if status == 0:
1245+
pipe = subprocess.Popen(['fc-match', '-sv', pattern], stdout=subprocess.PIPE)
1246+
output = pipe.communicate()[0]
1247+
if pipe.returncode == 0:
12521248
for match in _fc_match_regex.finditer(output):
12531249
file = match.group(1)
12541250
if os.path.splitext(file)[1][1:] in fontexts:

0 commit comments

Comments
 (0)