From 0a871f68805b0edda7ebc6a357c4ff8aae514758 Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Fri, 16 May 2014 12:03:59 +0200 Subject: [PATCH] Provide compatibility check_output for 2.6 (Fixes #2926) --- youtube_dl/postprocessor/xattrpp.py | 3 ++- youtube_dl/utils.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/youtube_dl/postprocessor/xattrpp.py b/youtube_dl/postprocessor/xattrpp.py index 18979241c..f6940940b 100644 --- a/youtube_dl/postprocessor/xattrpp.py +++ b/youtube_dl/postprocessor/xattrpp.py @@ -6,6 +6,7 @@ from .common import PostProcessor from ..utils import ( check_executable, hyphenate_date, + subprocess_check_output ) @@ -57,7 +58,7 @@ class XAttrMetadataPP(PostProcessor): elif user_has_xattr: cmd = ['xattr', '-w', key, value, path] - subprocess.check_output(cmd) + subprocess_check_output(cmd) else: # On Unix, and can't find pyxattr, setfattr, or xattr. diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 1036ea9bd..aa9347f43 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -1429,3 +1429,15 @@ def qualities(quality_ids): DEFAULT_OUTTMPL = '%(title)s-%(id)s.%(ext)s' + +try: + subprocess_check_output = subprocess.check_output +except AttributeError: + def subprocess_check_output(*args, **kwargs): + assert 'input' not in kwargs + p = subprocess.Popen(*args, stdout=subprocess.PIPE, **kwargs) + output, _ = p.communicate() + ret = p.poll() + if ret: + raise subprocess.CalledProcessError(ret, p.args, output=output) + return output