mirror of
https://github.com/beetbox/beets.git
synced 2025-12-07 17:16:07 +01:00
Remove bytes casting for non-path command args/opts
This commit is contained in:
parent
35c539b5a4
commit
2a6e74bc27
5 changed files with 18 additions and 18 deletions
|
|
@ -126,13 +126,13 @@ def check_art_similarity(log, item, imagepath, compare_threshold):
|
||||||
# Converting images to grayscale tends to minimize the weight
|
# Converting images to grayscale tends to minimize the weight
|
||||||
# of colors in the diff score.
|
# of colors in the diff score.
|
||||||
convert_proc = subprocess.Popen(
|
convert_proc = subprocess.Popen(
|
||||||
[b'convert', syspath(imagepath), syspath(art),
|
['convert', syspath(imagepath), syspath(art),
|
||||||
b'-colorspace', b'gray', b'MIFF:-'],
|
'-colorspace', 'gray', 'MIFF:-'],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
close_fds=not is_windows,
|
close_fds=not is_windows,
|
||||||
)
|
)
|
||||||
compare_proc = subprocess.Popen(
|
compare_proc = subprocess.Popen(
|
||||||
[b'compare', b'-metric', b'PHASH', b'-', b'null:'],
|
['compare', '-metric', 'PHASH', '-', 'null:'],
|
||||||
stdin=convert_proc.stdout,
|
stdin=convert_proc.stdout,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
|
|
|
||||||
|
|
@ -661,7 +661,7 @@ def cpu_count():
|
||||||
num = 0
|
num = 0
|
||||||
elif sys.platform == 'darwin':
|
elif sys.platform == 'darwin':
|
||||||
try:
|
try:
|
||||||
num = int(command_output([b'/usr/sbin/sysctl', b'-n', b'hw.ncpu']))
|
num = int(command_output(['/usr/sbin/sysctl', '-n', 'hw.ncpu']))
|
||||||
except (ValueError, OSError, subprocess.CalledProcessError):
|
except (ValueError, OSError, subprocess.CalledProcessError):
|
||||||
num = 0
|
num = 0
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,8 @@ def im_resize(maxwidth, path_in, path_out=None):
|
||||||
# compatibility.
|
# compatibility.
|
||||||
try:
|
try:
|
||||||
util.command_output([
|
util.command_output([
|
||||||
b'convert', util.syspath(path_in, prefix=False),
|
'convert', util.syspath(path_in, prefix=False),
|
||||||
b'-resize', b'{0}x^>'.format(maxwidth),
|
'-resize', '{0}x^>'.format(maxwidth),
|
||||||
util.syspath(path_out, prefix=False),
|
util.syspath(path_out, prefix=False),
|
||||||
])
|
])
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
|
|
@ -119,7 +119,7 @@ def pil_getsize(path_in):
|
||||||
|
|
||||||
|
|
||||||
def im_getsize(path_in):
|
def im_getsize(path_in):
|
||||||
cmd = [b'identify', b'-format', b'%w %h',
|
cmd = ['identify', '-format', '%w %h',
|
||||||
util.syspath(path_in, prefix=False)]
|
util.syspath(path_in, prefix=False)]
|
||||||
try:
|
try:
|
||||||
out = util.command_output(cmd)
|
out = util.command_output(cmd)
|
||||||
|
|
@ -233,7 +233,7 @@ def get_im_version():
|
||||||
"""Return Image Magick version or None if it is unavailable
|
"""Return Image Magick version or None if it is unavailable
|
||||||
Try invoking ImageMagick's "convert"."""
|
Try invoking ImageMagick's "convert"."""
|
||||||
try:
|
try:
|
||||||
out = util.command_output([b'identify', b'--version'])
|
out = util.command_output(['identify', '--version'])
|
||||||
|
|
||||||
if 'imagemagick' in out.lower():
|
if 'imagemagick' in out.lower():
|
||||||
pattern = r".+ (\d+)\.(\d+)\.(\d+).*"
|
pattern = r".+ (\d+)\.(\d+)\.(\d+).*"
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ class KeyFinderPlugin(BeetsPlugin):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
output = util.command_output([bin, b'-f',
|
output = util.command_output([bin, '-f',
|
||||||
util.syspath(item.path)])
|
util.syspath(item.path)])
|
||||||
except (subprocess.CalledProcessError, OSError) as exc:
|
except (subprocess.CalledProcessError, OSError) as exc:
|
||||||
self._log.error(u'execution failed: {0}', exc)
|
self._log.error(u'execution failed: {0}', exc)
|
||||||
|
|
|
||||||
|
|
@ -102,9 +102,9 @@ class Bs1770gainBackend(Backend):
|
||||||
'method': 'replaygain',
|
'method': 'replaygain',
|
||||||
})
|
})
|
||||||
self.chunk_at = config['chunk_at'].as_number()
|
self.chunk_at = config['chunk_at'].as_number()
|
||||||
self.method = b'--' + bytes(config['method'].get(unicode))
|
self.method = '--' + config['method'].get(unicode)
|
||||||
|
|
||||||
cmd = b'bs1770gain'
|
cmd = 'bs1770gain'
|
||||||
try:
|
try:
|
||||||
call([cmd, self.method])
|
call([cmd, self.method])
|
||||||
self.command = cmd
|
self.command = cmd
|
||||||
|
|
@ -195,7 +195,7 @@ class Bs1770gainBackend(Backend):
|
||||||
# Construct shell command.
|
# Construct shell command.
|
||||||
cmd = [self.command]
|
cmd = [self.command]
|
||||||
cmd = cmd + [self.method]
|
cmd = cmd + [self.method]
|
||||||
cmd = cmd + [b'-it']
|
cmd = cmd + ['-it']
|
||||||
|
|
||||||
# Workaround for Windows: the underlying tool fails on paths
|
# Workaround for Windows: the underlying tool fails on paths
|
||||||
# with the \\?\ prefix, so we don't use it here. This
|
# with the \\?\ prefix, so we don't use it here. This
|
||||||
|
|
@ -267,9 +267,9 @@ class CommandBackend(Backend):
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# Check whether the program is in $PATH.
|
# Check whether the program is in $PATH.
|
||||||
for cmd in (b'mp3gain', b'aacgain'):
|
for cmd in ('mp3gain', 'aacgain'):
|
||||||
try:
|
try:
|
||||||
call([cmd, b'-v'])
|
call([cmd, '-v'])
|
||||||
self.command = cmd
|
self.command = cmd
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
@ -334,14 +334,14 @@ class CommandBackend(Backend):
|
||||||
# tag-writing; this turns the mp3gain/aacgain tool into a gain
|
# tag-writing; this turns the mp3gain/aacgain tool into a gain
|
||||||
# calculator rather than a tag manipulator because we take care
|
# calculator rather than a tag manipulator because we take care
|
||||||
# of changing tags ourselves.
|
# of changing tags ourselves.
|
||||||
cmd = [self.command, b'-o', b'-s', b's']
|
cmd = [self.command, '-o', '-s', 's']
|
||||||
if self.noclip:
|
if self.noclip:
|
||||||
# Adjust to avoid clipping.
|
# Adjust to avoid clipping.
|
||||||
cmd = cmd + [b'-k']
|
cmd = cmd + ['-k']
|
||||||
else:
|
else:
|
||||||
# Disable clipping warning.
|
# Disable clipping warning.
|
||||||
cmd = cmd + [b'-c']
|
cmd = cmd + ['-c']
|
||||||
cmd = cmd + [b'-d', bytes(self.gain_offset)]
|
cmd = cmd + ['-d', self.gain_offset]
|
||||||
cmd = cmd + [syspath(i.path) for i in items]
|
cmd = cmd + [syspath(i.path) for i in items]
|
||||||
|
|
||||||
self._log.debug(u'analyzing {0} files', len(items))
|
self._log.debug(u'analyzing {0} files', len(items))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue