Skip to content

Commit

Permalink
Merge pull request #3235 from jenshnielsen/more_warnings
Browse files Browse the repository at this point in the history
Silence some more warnings
  • Loading branch information
mdboom committed Jul 21, 2014
2 parents 4314d44 + 461264e commit 053648a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 20 deletions.
32 changes: 20 additions & 12 deletions lib/matplotlib/__init__.py
Expand Up @@ -343,8 +343,9 @@ def checkdep_dvipng():
try:
s = subprocess.Popen(['dvipng','-version'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
line = s.stdout.readlines()[1]
v = line.split()[-1].decode('ascii')
stdout, stderr = s.communicate()
line = stdout.decode('ascii').split('\n')[1]
v = line.split()[-1]
return v
except (IndexError, ValueError, OSError):
return None
Expand All @@ -371,7 +372,8 @@ def checkdep_tex():
try:
s = subprocess.Popen(['tex','-version'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
line = s.stdout.readlines()[0].decode('ascii')
stdout, stderr = s.communicate()
line = stdout.decode('ascii').split('\n')[0]
pattern = '3\.1\d+'
match = re.search(pattern, line)
v = match.group(0)
Expand All @@ -383,9 +385,11 @@ def checkdep_pdftops():
try:
s = subprocess.Popen(['pdftops','-v'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
for line in s.stderr:
if b'version' in line:
v = line.split()[-1].decode('ascii')
stdout, stderr = s.communicate()
lines = stderr.decode('ascii').split('\n')
for line in lines:
if 'version' in line:
v = line.split()[-1]
return v
except (IndexError, ValueError, UnboundLocalError, OSError):
return None
Expand All @@ -394,9 +398,11 @@ def checkdep_inkscape():
try:
s = subprocess.Popen(['inkscape','-V'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
for line in s.stdout:
if b'Inkscape' in line:
v = line.split()[1].decode('ascii')
stdout, stderr = s.communicate()
lines = stdout.decode('ascii').split('\n')
for line in lines:
if 'Inkscape' in line:
v = line.split()[1]
break
return v
except (IndexError, ValueError, UnboundLocalError, OSError):
Expand All @@ -406,9 +412,11 @@ def checkdep_xmllint():
try:
s = subprocess.Popen(['xmllint','--version'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
for line in s.stderr:
if b'version' in line:
v = line.split()[-1].decode('ascii')
stdout, stderr = s.communicate()
lines = stderr.decode('ascii').split('\n')
for line in lines:
if 'version' in line:
v = line.split()[-1]
break
return v
except (IndexError, ValueError, UnboundLocalError, OSError):
Expand Down
9 changes: 5 additions & 4 deletions lib/matplotlib/backends/backend_ps.py
Expand Up @@ -90,12 +90,13 @@ def gs_version(self):
pass

from matplotlib.compat.subprocess import Popen, PIPE
pipe = Popen(self.gs_exe + " --version",
shell=True, stdout=PIPE).stdout
s = Popen(self.gs_exe + " --version",
shell=True, stdout=PIPE)
pipe, stderr = s.communicate()
if six.PY3:
ver = pipe.read().decode('ascii')
ver = pipe.decode('ascii')
else:
ver = pipe.read()
ver = pipe
gs_version = tuple(map(int, ver.strip().split(".")))

self._cached["gs_version"] = gs_version
Expand Down
2 changes: 2 additions & 0 deletions lib/matplotlib/tests/test_backend_ps.py
Expand Up @@ -40,6 +40,8 @@ def _test_savefig_to_stringio(format='ps'):

assert values[0] == values[1]
assert values[1] == values[2].replace(b'\r\n', b'\n')
for buffer in buffers:
buffer.close()


@cleanup
Expand Down
8 changes: 4 additions & 4 deletions lib/matplotlib/texmanager.py
Expand Up @@ -70,16 +70,16 @@ def dvipng_hack_alpha():
try:
p = Popen(['dvipng', '-version'], stdin=PIPE, stdout=PIPE,
stderr=STDOUT, close_fds=(sys.platform != 'win32'))
stdout, stderr = p.communicate()
except OSError:
mpl.verbose.report('No dvipng was found', 'helpful')
return False
stdin, stdout = p.stdin, p.stdout
for line in stdout:
if line.startswith(b'dvipng '):
lines = stdout.decode('ascii').split('\n')
for line in lines:
if line.startswith('dvipng '):
version = line.split()[-1]
mpl.verbose.report('Found dvipng version %s' % version,
'helpful')
version = version.decode('ascii')
version = distutils.version.LooseVersion(version)
return version < distutils.version.LooseVersion('1.6')
mpl.verbose.report('Unexpected response from dvipng -version', 'helpful')
Expand Down

0 comments on commit 053648a

Please sign in to comment.