From e471325bb60abd1ad1289983998e04a1d5ad49ee Mon Sep 17 00:00:00 2001 From: Roland Date: Tue, 23 May 2023 16:22:32 -0600 Subject: [PATCH] Raising FileNotFoundError instead of using assert. --- wrolpi/captions.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wrolpi/captions.py b/wrolpi/captions.py index cc30e735..130f81ba 100755 --- a/wrolpi/captions.py +++ b/wrolpi/captions.py @@ -65,8 +65,11 @@ def extract_captions(path: pathlib.Path) -> Optional[str]: with tempfile.TemporaryDirectory() as directory: directory = pathlib.Path(directory) file_path = directory / 'captions.vtt' + + if file_path.exists(): + raise FileNotFoundError(f'Cannot not extract captions when file already exists {path}') + cmd = (FFMPEG_BIN, '-i', str(path.absolute()), file_path) - assert not file_path.exists() try: subprocess.check_call(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) except subprocess.SubprocessError: