8000 Do not run Windows' file system convert tool by cgohlke · Pull Request #5460 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Do not run Windows' file system convert tool #5460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
On Windows, initialize the animation.convert_path setting from the Re…
…gistry
  • Loading branch information
cgohlke committed Nov 25, 2015
commit a30ec664e39c27feaef595d2d81046222ec9afee
27 changes: 23 additions & 4 deletions lib/matplotlib/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from matplotlib.cbook import iterable, is_string_like
from matplotlib.compat import subprocess
from matplotlib import verbose
from matplotlib import rcParams
from matplotlib import rcParams, rcParamsDefault

# Process creation flag for subprocess to prevent it raising a terminal
# window. See for example:
Expand Down Expand Up @@ -262,9 +262,7 @@ def isAvailable(cls):
Check to see if a MovieWriter subclass is actually available by
running the commandline tool.
'''
if platform.system() == 'Windows' and cls.bin_path() == 'convert':
# On Windows, the full path to convert must be specified in
# matplotlibrc since convert is also the name of a system tool.
if not cls.bin_path():
return False
try:
p = subprocess.Popen(cls.bin_path(),
Expand Down Expand Up @@ -549,6 +547,27 @@ def delay(self):
def output_args(self):
return [self.outfile]

@classmethod
def _init_from_registry(cls):
if sys.platform != 'win32' or rcParams[cls.exec_key] != 'convert':
return
from matplotlib.externals.six.moves import winreg
for flag in (0, winreg.KEY_WOW64_32KEY, winreg.KEY_WOW64_64KEY):
try:
hkey = winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE,
'Software\\Imagemagick\\Current',
0, winreg.KEY_QUERY_VALUE | flag)
binpath = winreg.QueryValueEx(hkey, 'BinPath')[0]
winreg.CloseKey(hkey)
binpath += '\\convert.exe'
break
except Exception:
binpath = ''
rcParams[cls.exec_key] = rcParamsDefault[cls.exec_key] = binpath


ImageMagickBase._init_from_registry()


@writers.register('imagemagick')
class ImageMagickWriter(MovieWriter, ImageMagickBase):
Expand Down
0