]> diplodocus.org Git - flac-archive/commitdiff
unify subprocess handling
author <epg@pretzelnet.org> <>
Thu, 27 Dec 2012 03:03:22 +0000 (19:03 -0800)
committer <epg@pretzelnet.org> <>
Thu, 27 Dec 2012 03:03:22 +0000 (19:03 -0800)
rewrite-tags

index c44a27b..d4ce48c 100755 (executable)
@@ -4,7 +4,6 @@ import os, sys
 import subprocess
 import tempfile
 from errno import EEXIST
 import subprocess
 import tempfile
 from errno import EEXIST
-from subprocess import Popen, PIPE
 
 from flac_archive.tags import Tags
 
 
 from flac_archive.tags import Tags
 
@@ -27,12 +26,13 @@ def get_tags(fn):
     tags = Tags()
 
     command = ['metaflac', '--no-utf8-convert', '--export-tags-to=-', fn]
     tags = Tags()
 
     command = ['metaflac', '--no-utf8-convert', '--export-tags-to=-', fn]
-    p = Popen(command, stdout=PIPE)
+    p = subprocess.Popen(command, stdout=subprocess.PIPE,
+                         stderr=subprocess.STDOUT)
     tags.load(p.stdout)
 
     status = p.wait()
     if status != 0:
     tags.load(p.stdout)
 
     status = p.wait()
     if status != 0:
-        raise SubprocessError(status, command=command, stderr=p.stderr)
+        raise SubprocessError(status, command=command, stderr=p.stdout)
 
     return tags
 
 
     return tags
 
@@ -41,7 +41,8 @@ def rewrite_track_tags(track, tags, fn, tmp):
     tmp.close()
     command = ['metaflac', '--no-utf8-convert', '--dont-use-padding',
                '--remove-all-tags', '--import-tags-from', tmp.name, fn]
     tmp.close()
     command = ['metaflac', '--no-utf8-convert', '--dont-use-padding',
                '--remove-all-tags', '--import-tags-from', tmp.name, fn]
-    p = Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+    p = subprocess.Popen(command, stdout=subprocess.PIPE,
+                         stderr=subprocess.STDOUT)
     stdout, stderr = p.communicate()
     status = p.wait()
     if status != 0:
     stdout, stderr = p.communicate()
     status = p.wait()
     if status != 0: