Skip to content

Commit ea88b7f

Browse files
committed
Moved the utils/extprocess.py to the cbooks module - deleted unused import in cbooks
1 parent 5db0cce commit ea88b7f

File tree

5 files changed

+46
-46
lines changed

5 files changed

+46
-46
lines changed

lib/matplotlib/backends/backend_pgf.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
from matplotlib import font_manager
2020
from matplotlib.ft2font import FT2Font
2121
from matplotlib.cbook import is_string_like, is_writable_file_like
22-
from matplotlib.utils.extprocess import check_output
22+
from matplotlib.cbook import check_output
23+
2324

2425
###############################################################################
2526

lib/matplotlib/cbook.py

+44-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
from weakref import ref, WeakKeyDictionary
1313
import cPickle
1414
import os.path
15-
import random
1615
from functools import reduce
1716

17+
import subprocess
18+
1819
import matplotlib
1920

2021
major, minor1, minor2, s, tmp = sys.version_info
@@ -1897,6 +1898,48 @@ def _putmask(a, mask, values):
18971898
return np.copyto(a, values, where=mask)
18981899

18991900

1901+
def _check_output(*popenargs, **kwargs):
1902+
r"""Run command with arguments and return its output as a byte
1903+
string.
1904+
1905+
If the exit code was non-zero it raises a CalledProcessError. The
1906+
CalledProcessError object will have the return code in the
1907+
returncode
1908+
attribute and output in the output attribute.
1909+
1910+
The arguments are the same as for the Popen constructor. Example:
1911+
1912+
>>> check_output(["ls", "-l", "/dev/null"])
1913+
'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n'
1914+
1915+
The stdout argument is not allowed as it is used internally.
1916+
To capture standard error in the result, use stderr=STDOUT.
1917+
1918+
>>> check_output(["/bin/sh", "-c",
1919+
... "ls -l non_existent_file ; exit 0"],
1920+
... stderr=STDOUT)
1921+
'ls: non_existent_file: No such file or directory\n'
1922+
"""
1923+
if 'stdout' in kwargs:
1924+
raise ValueError('stdout argument not allowed, it will be overridden.')
1925+
process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
1926+
output, unused_err = process.communicate()
1927+
retcode = process.poll()
1928+
if retcode:
1929+
cmd = kwargs.get("args")
1930+
if cmd is None:
1931+
cmd = popenargs[0]
1932+
raise subprocess.CalledProcessError(retcode, cmd, output=output)
1933+
return output
1934+
1935+
1936+
# python2.7's subprocess provides a check_output method
1937+
if hasattr(subprocess, 'check_output'):
1938+
check_output = subprocess.check_output
1939+
else:
1940+
check_output = _check_output
1941+
1942+
19001943
if __name__=='__main__':
19011944
assert( allequal([1,1,1]) )
19021945
assert(not allequal([1,1,0]) )

lib/matplotlib/utils/__init__.py

Whitespace-only changes.

lib/matplotlib/utils/extprocess.py

-43
This file was deleted.

setup.py

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
'matplotlib.testing',
6060
'matplotlib.testing.jpl_units',
6161
'matplotlib.tests',
62-
'matplotlib.utils',
6362
'mpl_toolkits',
6463
'mpl_toolkits.mplot3d',
6564
'mpl_toolkits.axes_grid',

0 commit comments

Comments
 (0)