8000 Use `subprocess` instead `os.system` also in the examples · matplotlib/matplotlib@86662d8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 86662d8

Browse files
committed
Use subprocess instead os.system also in the examples
1 parent 5208d74 commit 86662d8

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

examples/pylab_examples/mathtext_examples.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44
from __future__ import print_function
55
import matplotlib.pyplot as plt
6-
import os
6+
import subprocess
77
import sys
88
import re
99
import gc
@@ -120,6 +120,6 @@ def doall():
120120
fd.write("\\end{document}\n")
121121
fd.close()
122122

123-
os.system("pdflatex mathtext_examples.ltx")
123+
subprocess.call("pdflatex mathtext_examples.ltx", shell=True)
124124
else:
125125
doall()

examples/pylab_examples/movie_demo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import print_function
44

5-
import os
5+
import subprocess
66
import matplotlib.pyplot as plt
77
import numpy as np
88

@@ -22,8 +22,8 @@
2222
files.append(fname)
2323

2424
print('Making movie animation.mpg - this may take a while')
25-
os.system("mencoder 'mf://_tmp*.png' -mf type=png:fps=10 -ovc lavc -lavcopts vcodec=wmv2 -oac copy -o animation.mpg")
26-
#os.system("convert _tmp*.png animation.mng")
25+
subprocess.call("mencoder 'mf://_tmp*.png' -mf type=png:fps=10 -ovc lavc -lavcopts vcodec=wmv2 -oac copy -o animation.mpg", shell=True)
26+
#subprocess.call("convert _tmp*.png animation.mng", shell=True)
2727

2828
# cleanup
2929
for fname in files:

examples/pylab_examples/stix_fonts_demo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import unicode_literals
22

3-
import os
3+
import subprocess
44
import sys
55
import re
66
import gc
@@ -53,6 +53,6 @@ def doall():
5353
fd.write("\\end{document}\n")
5454
fd.close()
5555

56-
os.system("pdflatex stix_fonts_examples.ltx")
56+
subprocess.call("pdflatex stix_fonts_examples.ltx", shell=True)
5757
else:
5858
doall()

examples/tests/backend_driver.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import os
2222
import time
23+
import subprocess
2324
import sys
2425
import glob
2526
from optparse import OptionParser
@@ -357,7 +358,7 @@ def run(arglist):
357358
return ret
358359
except ImportError:
359360
def run(arglist):
360-
os.system(' '.join(arglist))
361+
subprocess.call(' '.join(arglist), shell=True)
361362

362363

363364
def drive(backend, directories, python=['python'], switches=[]):
@@ -428,7 +429,7 @@ def drive(backend, directories, python=['python'], switches=[]):
428429
ret = run(program + [tmpfile_name] + switches)
429430
end_time = time.time()
430431
print("%s %s" % ((end_time - start_time), ret))
431-
#os.system('%s %s %s' % (python, tmpfile_name, ' '.join(switches)))
432+
#subprocess.call('%s %s %s' % (python, tmpfile_name, ' '.join(switches)), shell=True)
432433
os.remove(tmpfile_name)
433434
if ret:
434435
failures.append(fullpath)

0 commit comments

Comments
 (0)
0