+def rewrite_track_tags(track, tags, fn, tmp):
+ tmp.write('\n'.join(tags.track(track)) + '\n')
+ 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)
+ stdout, stderr = p.communicate()
+ status = p.wait()
+ if status != 0:
+ raise SubprocessError(status, command=command, stderr=stdout)
+