Skip to content

Commit

Permalink
Merge branch 'convert_exe_detection' of https://github.com/ig0774/LaT…
Browse files Browse the repository at this point in the history
  • Loading branch information
ig0774 committed Mar 13, 2017
2 parents 3ffc933 + 24770e3 commit bf095bb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
19 changes: 15 additions & 4 deletions st_preview/preview_utils.py
Expand Up @@ -6,12 +6,16 @@

import sublime

try:
if sublime.platform() == 'windows':
import winreg
except:
# not on Windows
pass
import ctypes
from ctypes import wintypes

# wrapper for GetSystemDirectoryW
def get_system_root():
buffer = ctypes.create_unicode_buffer(wintypes.MAX_PATH + 1)
ctypes.windll.kernel32.GetSystemDirectoryW(buffer, len(buffer))
return buffer.value

from ..latextools_utils import cache, get_setting
from ..latextools_utils.distro_utils import using_miktex
Expand All @@ -33,6 +37,13 @@ def _get_convert_command():
which('magick', path=texpath) or
which('convert', path=texpath)
)

# DO NOT RUN THE CONVERT COMMAND IN THE SYSTEM ROOT ON WINDOWS
if (sublime.platform() == 'windows' and
_get_convert_command.result.lower().endswith('convert.exe')):
system_root = get_system_root().lower()
if _get_convert_command.result.lower().startswith(system_root):
_get_convert_command.result = None
return _get_convert_command.result


Expand Down
11 changes: 7 additions & 4 deletions system_check.py
Expand Up @@ -60,7 +60,8 @@
_HAS_PREVIEW = sublime.version() >= '3118'
if _HAS_PREVIEW:
from .st_preview.preview_utils import (
convert_installed, ghostscript_installed, __get_gs_command as get_gs_command
convert_installed, ghostscript_installed,
__get_gs_command as get_gs_command
)

if sys.version_info >= (3,):
Expand Down Expand Up @@ -440,7 +441,7 @@ def run(self):

table.append([
'sublime',
sublime_exe,
sublime_exe if available and version_info is not None else u'',
(u'available'
if available and version_info is not None else u'missing'),
version_info if version_info is not None else u'unavailable'
Expand Down Expand Up @@ -492,7 +493,7 @@ def run(self):

table.append([
program,
location,
location if available and version_info is not None else u'',
available_str,
version_info if version_info is not None else u'unavailable'
])
Expand Down Expand Up @@ -520,7 +521,9 @@ def run(self):
available_str = u'restart required'

table.append([
program, location, available_str,
program,
location if available and version_info is not None else u'',
available_str,
version_info if version_info is not None else u'unavailable'
])

Expand Down

0 comments on commit bf095bb

Please sign in to comment.