Skip to content

Instantly share code, notes, and snippets.

@rvasilevsk
Last active February 12, 2021 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rvasilevsk/102285a38639fa811f8ddeda7038e4a6 to your computer and use it in GitHub Desktop.
Save rvasilevsk/102285a38639fa811f8ddeda7038e4a6 to your computer and use it in GitHub Desktop.
where, which, executable_exists #python.shellutils
# [pyperclip/__init__.py at master · asweigart/pyperclip](https://github.com/asweigart/pyperclip/blob/master/src/pyperclip/__init__.py)
try:
from shutil import which as _executable_exists
except ImportError:
# The "which" unix command finds where a command is.
if platform.system() == 'Windows':
WHICH_CMD = 'where'
else:
WHICH_CMD = 'which'
def _executable_exists(name):
return subprocess.call([WHICH_CMD, name],
stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment