Skip to content

Commit fa0f509

Browse files
committed
Use subprocess instead os.system also in the examples
1 parent b136e9e commit fa0f509

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-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: 5 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,10 @@
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",
26+
"-ovc", "lavc", "-lavcopts", "vcodec=wmv2", "-oac", "copy",
27+
"-o", "animation.mpg"])
28+
#subprocess.call(["convert", "_tmp*.png", "animation.mng"])
2729

2830
# cleanup
2931
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
@@ -350,7 +350,7 @@ def run(arglist):
350350
return ret
351351
except ImportError:
352352
def run(arglist):
353-
os.system(' '.join(arglist))
353+
os.system(arglist)
354354

355355

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

0 commit comments

Comments
 (0)