From b4d3ac87de8ec7a91c62c3abe011704bd065c30f Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 19 Jan 2020 21:00:16 -0800 Subject: [PATCH] Avoid winshell import error for linux. --- voussoirkit/winwhich.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/voussoirkit/winwhich.py b/voussoirkit/winwhich.py index eb59af4..ed4fcd1 100644 --- a/voussoirkit/winwhich.py +++ b/voussoirkit/winwhich.py @@ -12,7 +12,10 @@ return the exe path, otherwise behaves the same as normal shutil which. ''' import os import shutil -import winshell +try: + import winshell +except ImportError: + winshell = None def which(cmd, *args, **kwargs): path = shutil.which(cmd, *args, **kwargs) @@ -20,7 +23,7 @@ def which(cmd, *args, **kwargs): if path is 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 return path