Skip to content

Commit ba41e08

Browse files
committed
Use subprocess instead os.system also in the examples
1 parent 3e94f67 commit ba41e08

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-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"])
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 "
26+
"-lavcopts vcodec=wmv2 -oac copy -o animation.mpg", 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"])
5757
else:
5858
doall()

examples/tests/backend_driver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def run(arglist):
349349
return ret
350350
except ImportError:
351351
def run(arglist):
352-
os.system(' '.join(arglist))
352+
os.system(arglist)
353353

354354

355355
def drive(backend, directories, python=['python'], switches=[]):
@@ -420,7 +420,7 @@ def drive(backend, directories, python=['python'], switches=[]):
420420
ret = run(program + [tmpfile_name] + switches)
421421
end_time = time.time()
422422
print("%s %s" % ((end_time - start_time), ret))
423-
#os.system('%s %s %s' % (python, tmpfile_name, ' '.join(switches)))
423+
# subprocess.call([python, tmpfile_name] + switches)
424424
os.remove(tmpfile_name)
425425
if ret:
426426
failures.append(fullpath)

0 commit comments

Comments
 (0)