X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Futils.py;h=73fe1ad0a3a27165d3dffc61927733beb9c5ed33;hb=7ee40b5d1cf0d4e79a049f3851262378c08d9e4c;hp=a509f8e2f1b667ac43910b72bf4e30b27e64c355;hpb=5f263296eaa72ddca232d734a2625bcd85771908;p=youtube-dl 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