mirror of
https://github.com/beetbox/beets.git
synced 2025-12-10 10:32:34 +01:00
Fix test.helper.has_program(): encode command
subprocess.subprocess.check_call() should receive a byte string command otherwise it fails with a UnicodeDecodeError on systems with non-ascii elements in the system path. Discovered while reviewing PR #1344.
This commit is contained in:
parent
8113c7ba85
commit
69786b8538
1 changed files with 6 additions and 1 deletions
|
|
@ -51,6 +51,7 @@ from beets.library import Library, Item, Album
|
|||
from beets import importer
|
||||
from beets.autotag.hooks import AlbumInfo, TrackInfo
|
||||
from beets.mediafile import MediaFile, Image
|
||||
from beets.ui import _encoding
|
||||
|
||||
# TODO Move AutotagMock here
|
||||
from test import _common
|
||||
|
|
@ -117,9 +118,13 @@ def capture_stdout():
|
|||
def has_program(cmd, args=['--version']):
|
||||
"""Returns `True` if `cmd` can be executed.
|
||||
"""
|
||||
full_cmd = [cmd] + args
|
||||
for i, elem in enumerate(full_cmd):
|
||||
if isinstance(elem, unicode):
|
||||
full_cmd[i] = elem.encode(_encoding())
|
||||
try:
|
||||
with open(os.devnull, 'wb') as devnull:
|
||||
subprocess.check_call([cmd] + args, stderr=devnull,
|
||||
subprocess.check_call(full_cmd, stderr=devnull,
|
||||
stdout=devnull, stdin=devnull)
|
||||
except OSError:
|
||||
return False
|
||||
|
|
|
|||
Loading…
Reference in a new issue