Provide compatibility check_output for 2.6 (Fixes #2926)
authorPhilipp Hagemeister <phihag@phihag.de>
Fri, 16 May 2014 10:03:59 +0000 (12:03 +0200)
committerPhilipp Hagemeister <phihag@phihag.de>
Fri, 16 May 2014 10:03:59 +0000 (12:03 +0200)
youtube_dl/postprocessor/xattrpp.py
youtube_dl/utils.py

index 18979241cd9f0bb70cf2d8e9c00709ec43db1fea..f6940940b340dea5c23e5ce118b8fcc4d7ee8574 100644 (file)
@@ -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.
index 1036ea9bd87789bca51e8cbc2b8091e7b5f96bc3..aa9347f431ba5961b39e681fb4721933215d221b 100644 (file)
@@ -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