Avoid winshell import error for linux.
This commit is contained in:
parent
fee0871ef4
commit
b4d3ac87de
1 changed files with 5 additions and 2 deletions
|
@ -12,7 +12,10 @@ return the exe path, otherwise behaves the same as normal shutil which.
|
||||||
'''
|
'''
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
try:
|
||||||
import winshell
|
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
|
||||||
|
|
Loading…
Reference in a new issue