Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2e9ff44

Browse files
cgohlketacaswell
authored andcommitted
Manual backport of #5460 to v1.5.x
This commit squashes 87c968b a30ec66 and cherry-picks them to the v1.5.x branch. These commits were merged to master as part of #5604 which was not backported en-mass. Original commit messages: Do not run Windows' file system convert tool On Windows, initialize the animation.convert_path setting from the Registry
1 parent 3963769 commit 2e9ff44

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

lib/matplotlib/animation.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from matplotlib.cbook import iterable, is_string_like
3939
from matplotlib.compat import subprocess
4040
from matplotlib import verbose
41-
from matplotlib import rcParams
41+
from matplotlib import rcParams, rcParamsDefault
4242

4343
# Process creation flag for subprocess to prevent it raising a terminal
4444
# window. See for example:
@@ -267,6 +267,8 @@ def isAvailable(cls):
267267
Check to see if a MovieWriter subclass is actually available by
268268
running the commandline tool.
269269
'''
270+
if not cls.bin_path():
271+
return False
270272
try:
271273
p = subprocess.Popen(cls.bin_path(),
272274
shell=False,
@@ -550,6 +552,27 @@ def delay(self):
550552
def output_args(self):
551553
return [self.outfile]
552554

555+
@classmethod
556+
def _init_from_registry(cls):
557+
if sys.platform != 'win32' or rcParams[cls.exec_key] != 'convert':
558+
return
559+
from matplotlib.externals.six.moves import winreg
560+
for flag in (0, winreg.KEY_WOW64_32KEY, winreg.KEY_WOW64_64KEY):
561+
try:
562+
hkey = winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE,
563+
'Software\\Imagemagick\\Current',
564+
0, winreg.KEY_QUERY_VALUE | flag)
565+
binpath = winreg.QueryValueEx(hkey, 'BinPath')[0]
566+
winreg.CloseKey(hkey)
567+
binpath += '\\convert.exe'
568+
break
569+
except Exception:
570+
binpath = ''
571+
rcParams[cls.exec_key] = rcParamsDefault[cls.exec_key] = binpath
572+
573+
574+
ImageMagickBase._init_from_registry()
575+
553576

554577
@writers.register('imagemagick')
555578
class ImageMagickWriter(MovieWriter, ImageMagickBase):

0 commit comments

Comments
 (0)