aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2014-01-07 06:23:41 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2014-01-07 06:23:41 +0100
commitd70ad093af56330d19eabe54483cbbd44b1bf6c1 (patch)
treeb712aa68c300233f65c340a306289cbf97a720af /youtube_dl/utils.py
parent2a2e2770cc216e3a0d29eb3d164b62bc97938176 (diff)
downloadyoutube-dl-d70ad093af56330d19eabe54483cbbd44b1bf6c1.tar.xz
Move check_executable into a helper ufnction
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r--youtube_dl/utils.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index a509f8e2f..73fe1ad0a 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -1151,3 +1151,13 @@ def parse_duration(s):
def prepend_extension(filename, ext):
name, real_ext = os.path.splitext(filename)
return u'{0}.{1}{2}'.format(name, ext, real_ext)
+
+
+def check_executable(exe, args=[]):
+ """ Checks if the given binary is installed somewhere in PATH, and returns its name.
+ args can be a list of arguments for a short output (like -version) """
+ try:
+ subprocess.Popen([exe] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
+ except OSError:
+ return False
+ return exe