mirror of
https://github.com/kkroening/ffmpeg-python.git
synced 2025-08-07 18:39:47 +08:00
Windows: Fix newline differences
This commit is contained in:
parent
c04c2e9c35
commit
89464c8f82
@ -63,13 +63,14 @@ def _run(args):
|
|||||||
Run the command and return stdout but only print stderr on failure.
|
Run the command and return stdout but only print stderr on failure.
|
||||||
"""
|
"""
|
||||||
process = subprocess.Popen(
|
process = subprocess.Popen(
|
||||||
args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||||
|
universal_newlines=True)
|
||||||
stdout, stderr = process.communicate()
|
stdout, stderr = process.communicate()
|
||||||
if process.returncode != 0:
|
if process.returncode != 0:
|
||||||
logger.error(stderr.decode())
|
logger.error(stderr)
|
||||||
raise subprocess.CalledProcessError(
|
raise subprocess.CalledProcessError(
|
||||||
process.returncode, process.args, output=stdout, stderr=stderr)
|
process.returncode, process.args, output=stdout, stderr=stderr)
|
||||||
return stdout.decode()
|
return stdout
|
||||||
|
|
||||||
|
|
||||||
def _get_line_fields(
|
def _get_line_fields(
|
||||||
|
@ -75,9 +75,9 @@ def detect_gpus():
|
|||||||
if plat_sys == 'Linux':
|
if plat_sys == 'Linux':
|
||||||
# TODO: Android and other Linux'es that don't have `lshw`
|
# TODO: Android and other Linux'es that don't have `lshw`
|
||||||
display_output = subprocess.check_output(
|
display_output = subprocess.check_output(
|
||||||
['lshw', '-class', 'display', '-json'])
|
['lshw', '-class', 'display', '-json'], universal_newlines=True)
|
||||||
displays_data = json.loads(
|
displays_data = json.loads(
|
||||||
display_output.decode().strip().strip(','),
|
display_output.strip().strip(','),
|
||||||
object_pairs_hook=collections.OrderedDict)
|
object_pairs_hook=collections.OrderedDict)
|
||||||
if not isinstance(displays_data, list):
|
if not isinstance(displays_data, list):
|
||||||
# TODO: Confirm this is how `lshw` handles multiple GPUs
|
# TODO: Confirm this is how `lshw` handles multiple GPUs
|
||||||
|
@ -22,12 +22,13 @@ def probe(filename, cmd='ffprobe', **kwargs):
|
|||||||
args += convert_kwargs_to_cmd_line_args(kwargs)
|
args += convert_kwargs_to_cmd_line_args(kwargs)
|
||||||
args += [filename]
|
args += [filename]
|
||||||
|
|
||||||
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
p = subprocess.Popen(
|
||||||
|
args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||||
|
universal_newlines=True)
|
||||||
out, err = p.communicate()
|
out, err = p.communicate()
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
raise Error('ffprobe', out, err)
|
raise Error('ffprobe', out, err)
|
||||||
return json.loads(
|
return json.loads(out, object_pairs_hook=collections.OrderedDict)
|
||||||
out.decode('utf-8'), object_pairs_hook=collections.OrderedDict)
|
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['probe']
|
__all__ = ['probe']
|
||||||
|
@ -9,6 +9,8 @@ import random
|
|||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import mock # python 2
|
import mock # python 2
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -710,7 +712,7 @@ def test__probe__exception():
|
|||||||
with pytest.raises(ffmpeg.Error) as excinfo:
|
with pytest.raises(ffmpeg.Error) as excinfo:
|
||||||
ffmpeg.probe(BOGUS_INPUT_FILE)
|
ffmpeg.probe(BOGUS_INPUT_FILE)
|
||||||
assert str(excinfo.value) == 'ffprobe error (see stderr output for detail)'
|
assert str(excinfo.value) == 'ffprobe error (see stderr output for detail)'
|
||||||
assert 'No such file or directory'.encode() in excinfo.value.stderr
|
assert 'No such file or directory' in excinfo.value.stderr
|
||||||
|
|
||||||
|
|
||||||
def test__probe__extra_args():
|
def test__probe__extra_args():
|
||||||
@ -725,11 +727,11 @@ def test__build_data():
|
|||||||
'protocols', 'filters', 'pix_fmts', 'sample_fmts', 'layouts',
|
'protocols', 'filters', 'pix_fmts', 'sample_fmts', 'layouts',
|
||||||
'colors', 'devices', 'hw_devices', 'hwaccels'}
|
'colors', 'devices', 'hw_devices', 'hwaccels'}
|
||||||
|
|
||||||
assert isinstance(data['version'], str)
|
assert isinstance(data['version'], six.string_types)
|
||||||
|
|
||||||
assert isinstance(data['codecs'], dict)
|
assert isinstance(data['codecs'], dict)
|
||||||
for codec, coders in data['codecs'].items():
|
for codec, coders in data['codecs'].items():
|
||||||
assert isinstance(codec, str)
|
assert isinstance(codec, six.string_types)
|
||||||
assert isinstance(coders, dict)
|
assert isinstance(coders, dict)
|
||||||
assert isinstance(data['hwaccels'], list)
|
assert isinstance(data['hwaccels'], list)
|
||||||
for hwaccel in data['hwaccels']:
|
for hwaccel in data['hwaccels']:
|
||||||
@ -766,7 +768,9 @@ def test__detect():
|
|||||||
assert 'output' in codec_kwargs
|
assert 'output' in codec_kwargs
|
||||||
assert isinstance(codec_kwargs['output'], dict)
|
assert isinstance(codec_kwargs['output'], dict)
|
||||||
assert 'codec' in codec_kwargs['output']
|
assert 'codec' in codec_kwargs['output']
|
||||||
assert isinstance(codec_kwargs['output']['codec'], str)
|
assert isinstance(
|
||||||
|
codec_kwargs['output']['codec'],
|
||||||
|
six.string_types)
|
||||||
|
|
||||||
|
|
||||||
def test__detect_parse_models():
|
def test__detect_parse_models():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user