|
23 | 23 | import six |
24 | 24 | from six.moves import xrange, zip |
25 | 25 |
|
| 26 | +import platform |
26 | 27 | import sys |
27 | 28 | import itertools |
28 | 29 | import contextlib |
|
31 | 32 | from matplotlib import verbose |
32 | 33 | from matplotlib import rcParams |
33 | 34 |
|
| 35 | +# Process creation flag for subprocess to prevent it raising a terminal |
| 36 | +# window. See for example: |
| 37 | +# https://stackoverflow.com/questions/24130623/using-python-subprocess-popen-cant-prevent-exe-stopped-working-prompt |
| 38 | +if platform.system() == 'Windows': |
| 39 | + CREATE_NO_WINDOW = 0x08000000 |
| 40 | + subprocess_creation_flags = CREATE_NO_WINDOW |
| 41 | +else: |
| 42 | + # Apparently None won't work here |
| 43 | + subprocess_creation_flags = 0 |
| 44 | + |
34 | 45 | # Other potential writing methods: |
35 | 46 | # * http://pymedia.org/ |
36 | 47 | # * libmng (produces swf) python wrappers: https://github.com/libming/libming |
@@ -189,7 +200,8 @@ def _run(self): |
189 | 200 | ' '.join(command)) |
190 | 201 | self._proc = subprocess.Popen(command, shell=False, |
191 | 202 | stdout=output, stderr=output, |
192 | | - stdin=subprocess.PIPE) |
| 203 | + stdin=subprocess.PIPE, |
| 204 | + creationflags=subprocess_creation_flags) |
193 | 205 |
|
194 | 206 | def finish(self): |
195 | 207 | 'Finish any processing for writing the movie.' |
@@ -251,7 +263,8 @@ def isAvailable(cls): |
251 | 263 | p = subprocess.Popen(cls.bin_path(), |
252 | 264 | shell=False, |
253 | 265 | stdout=subprocess.PIPE, |
254 | | - stderr=subprocess.PIPE) |
| 266 | + stderr=subprocess.PIPE, |
| 267 | + creationflags=subprocess_creation_flags) |
255 | 268 | p.communicate() |
256 | 269 | return True |
257 | 270 | except OSError: |
|
0 commit comments