mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
removebyte conversion/literals for command args
Paths are obviously untouched. We definitely don't need these as they are entirely ascii.
This commit is contained in:
parent
774d9c33b2
commit
6bedbd84df
5 changed files with 19 additions and 19 deletions
|
|
@ -723,7 +723,7 @@ def cpu_count():
|
|||
num = 0
|
||||
elif sys.platform == 'darwin':
|
||||
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):
|
||||
num = 0
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -91,8 +91,8 @@ def im_resize(maxwidth, path_in, path_out=None):
|
|||
# compatibility.
|
||||
try:
|
||||
util.command_output([
|
||||
b'convert', util.syspath(path_in, prefix=False),
|
||||
b'-resize', b'{0}x^>'.format(maxwidth),
|
||||
'convert', util.syspath(path_in, prefix=False),
|
||||
'-resize', '{0}x^>'.format(maxwidth),
|
||||
util.syspath(path_out, prefix=False),
|
||||
])
|
||||
except subprocess.CalledProcessError:
|
||||
|
|
@ -119,7 +119,7 @@ def pil_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)]
|
||||
try:
|
||||
out = util.command_output(cmd)
|
||||
|
|
@ -233,7 +233,7 @@ def get_im_version():
|
|||
Try invoking ImageMagick's "convert".
|
||||
"""
|
||||
try:
|
||||
out = util.command_output([b'convert', b'--version'])
|
||||
out = util.command_output(['convert', '--version'])
|
||||
|
||||
if b'imagemagick' in out.lower():
|
||||
pattern = br".+ (\d+)\.(\d+)\.(\d+).*"
|
||||
|
|
|
|||
|
|
@ -52,14 +52,14 @@ class KeyFinderPlugin(BeetsPlugin):
|
|||
|
||||
def find_key(self, items, write=False):
|
||||
overwrite = self.config['overwrite'].get(bool)
|
||||
bin = util.bytestring_path(self.config['bin'].as_str())
|
||||
bin = self.config['bin'].as_str()
|
||||
|
||||
for item in items:
|
||||
if item['initial_key'] and not overwrite:
|
||||
continue
|
||||
|
||||
try:
|
||||
output = util.command_output([bin, b'-f',
|
||||
output = util.command_output([bin, '-f',
|
||||
util.syspath(item.path)])
|
||||
except (subprocess.CalledProcessError, OSError) as exc:
|
||||
self._log.error(u'execution failed: {0}', exc)
|
||||
|
|
|
|||
|
|
@ -102,9 +102,9 @@ class Bs1770gainBackend(Backend):
|
|||
'method': 'replaygain',
|
||||
})
|
||||
self.chunk_at = config['chunk_at'].as_number()
|
||||
self.method = b'--' + config['method'].as_str().encode('ascii')
|
||||
self.method = '--' + config['method'].as_str()
|
||||
|
||||
cmd = b'bs1770gain'
|
||||
cmd = 'bs1770gain'
|
||||
try:
|
||||
call([cmd, self.method])
|
||||
self.command = cmd
|
||||
|
|
@ -195,7 +195,7 @@ class Bs1770gainBackend(Backend):
|
|||
# Construct shell command.
|
||||
cmd = [self.command]
|
||||
cmd = cmd + [self.method]
|
||||
cmd = cmd + [b'-p']
|
||||
cmd = cmd + ['-p']
|
||||
|
||||
# Workaround for Windows: the underlying tool fails on paths
|
||||
# with the \\?\ prefix, so we don't use it here. This
|
||||
|
|
@ -267,9 +267,9 @@ class CommandBackend(Backend):
|
|||
)
|
||||
else:
|
||||
# Check whether the program is in $PATH.
|
||||
for cmd in (b'mp3gain', b'aacgain'):
|
||||
for cmd in ('mp3gain', 'aacgain'):
|
||||
try:
|
||||
call([cmd, b'-v'])
|
||||
call([cmd, '-v'])
|
||||
self.command = cmd
|
||||
except OSError:
|
||||
pass
|
||||
|
|
@ -308,9 +308,9 @@ class CommandBackend(Backend):
|
|||
def format_supported(self, item):
|
||||
"""Checks whether the given item is supported by the selected tool.
|
||||
"""
|
||||
if b'mp3gain' in self.command and item.format != 'MP3':
|
||||
if 'mp3gain' in self.command and item.format != 'MP3':
|
||||
return False
|
||||
elif b'aacgain' in self.command and item.format not in ('MP3', 'AAC'):
|
||||
elif 'aacgain' in self.command and item.format not in ('MP3', 'AAC'):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
|
@ -334,14 +334,14 @@ class CommandBackend(Backend):
|
|||
# tag-writing; this turns the mp3gain/aacgain tool into a gain
|
||||
# calculator rather than a tag manipulator because we take care
|
||||
# of changing tags ourselves.
|
||||
cmd = [self.command, b'-o', b'-s', b's']
|
||||
cmd = [self.command, '-o', '-s', 's']
|
||||
if self.noclip:
|
||||
# Adjust to avoid clipping.
|
||||
cmd = cmd + [b'-k']
|
||||
cmd = cmd + ['-k']
|
||||
else:
|
||||
# Disable clipping warning.
|
||||
cmd = cmd + [b'-c']
|
||||
cmd = cmd + [b'-d', str(self.gain_offset).encode('ascii')]
|
||||
cmd = cmd + ['-c']
|
||||
cmd = cmd + ['-d', str(self.gain_offset)]
|
||||
cmd = cmd + [syspath(i.path) for i in items]
|
||||
|
||||
self._log.debug(u'analyzing {0} files', len(items))
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class KeyFinderTest(unittest.TestCase, TestHelper):
|
|||
item.load()
|
||||
self.assertEqual(item['initial_key'], 'C#m')
|
||||
command_output.assert_called_with(
|
||||
[b'KeyFinder', b'-f', util.syspath(item.path)])
|
||||
['KeyFinder', '-f', util.syspath(item.path)])
|
||||
|
||||
def test_add_key_on_import(self, command_output):
|
||||
command_output.return_value = 'dbm'
|
||||
|
|
|
|||
Loading…
Reference in a new issue