Avoid winshell import error for linux.

This commit is contained in:
Ethan Dalool 2020-01-19 21:00:16 -08:00
parent fee0871ef4
commit b4d3ac87de

View file

@ -12,7 +12,10 @@ return the exe path, otherwise behaves the same as normal shutil which.
''' '''
import os import os
import shutil import shutil
import winshell try:
import winshell
except ImportError:
winshell = None
def which(cmd, *args, **kwargs): def which(cmd, *args, **kwargs):
path = shutil.which(cmd, *args, **kwargs) path = shutil.which(cmd, *args, **kwargs)
@ -20,7 +23,7 @@ def which(cmd, *args, **kwargs):
if path is None: if path is None:
return None return None
if os.name == 'nt' and path.lower().endswith('.lnk'): if os.name == 'nt' and winshell and path.lower().endswith('.lnk'):
path = winshell.Shortcut(path).path path = winshell.Shortcut(path).path
return path return path