8000 Remove precmd from backend_ps and use subprocess · matplotlib/matplotlib@1140314 · GitHub
[go: up one dir, main page]

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 1140314

Browse files
committed
Remove precmd from backend_ps and use subprocess
1 parent 25cd152 commit 1140314

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

lib/matplotlib/backends/backend_ps.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,19 +1458,16 @@ def convert_psfrags(tmpfile, psfrags, font_preamble, custom_preamble,
14581458
"rcParam.", 'helpful')
14591459
raise
14601460

1461-
# the split drive part of the command is necessary for windows users with
1462-
# multiple
1463-
if sys.platform == 'win32': precmd = '%s &&'% os.path.splitdrive(tmpdir)[0]
1464-
else: precmd = ''
14651461
#Replace \\ for / so latex does not think there is a function call
14661462
latexfile = latexfile.replace("\\", "/")
14671463
# Replace ~ so Latex does not think it is line break
14681464
latexfile = latexfile.replace("~", "\\string~")
14691465
command = [str('latex'), '-interction=nonstopmode', '"%s"' % (latexfile)]
14701466
verbose.report(command, 'debug')
14711467
try:
1472-
output = subprocess.check_output(command, shell=True,
1473-
stderr=subprocess.STDOUT)
1468+
with open(outfile, "w") as fout:
1469+
subprocess.check_call(command, cwd=tmpdir,
1470+
stdout=fout, stderr=subprocess.STDOUT)
14741471
except subprocess.CalledProcessError as exc:
14751472
with io.open(outfile, 'rb') as fh:
14761473
raise RuntimeError('LaTeX was not able to process your file: '
@@ -1481,12 +1478,13 @@ def convert_psfrags(tmpfile, psfrags, font_preamble, custom_preamble,
14811478
verbose.report(fh.read(), 'debug')
14821479
os.remove(outfile)
14831480

1484-
command = '%s cd "%s" && dvips -q -R0 -o "%s" "%s" > "%s"'%(precmd, tmpdir,
1485-
os.path.split(psfile)[-1], os.path.split(dvifile)[-1], outfile)
1481+
command = ['dvips', '-q', '-R0', '-o', '"%s"' % os.path.basename(psfile),
1482+
'"%s"' % os.path.basename(dvifile)]
14861483
verbose.report(command, 'debug')
14871484
try:
1488-
output = subprocess.check_output(command, shell=True,
1489-
stderr=subprocess.STDOUT)
1485+
with open(outfile, "w") as fout:
1486+
subprocess.check_call(command, cwd=tmpdir,
1487+
stdout=fout, stderr=subprocess.STDOUT)
14901488
except subprocess.CalledProcessError as exc:
14911489
with io.open(outfile, 'rb') as fh:
14921490
raise RuntimeError('dvips was not able to process the following '

0 commit comments

Comments
 (0)
0