Skip to content

Commit 6fef444

Browse files
authored
FfmpegMediaTypeError (#37)
1 parent 64ea8c1 commit 6fef444

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/ffmpeg_media_type/exceptions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class FfmpegMediaTypeError(Exception):
2+
pass

src/ffmpeg_media_type/utils/shell.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
import shlex
33
import tempfile
44

5+
from ..exceptions import FfmpegMediaTypeError
6+
57

68
def call(cmds: list[str]) -> str:
79
# call command and return stdout
810

911
command = " ".join(shlex.quote(part) for part in cmds)
1012
with tempfile.TemporaryDirectory() as tmpdir:
1113
output_path = f"{tmpdir}/output.txt"
12-
assert os.system(f"{command} > {output_path}") == 0, f"command failed: {command}"
14+
if os.system(f"{command} > {output_path}") != 0:
15+
raise FfmpegMediaTypeError(f"command failed: {command}")
1316

1417
with open(output_path) as ifile:
1518
return ifile.read()

0 commit comments

Comments
 (0)