From 0ccfa7470925a43e86f168d98889fb1cbb263185 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Fri, 17 Aug 2018 22:05:47 -0700 Subject: [PATCH] Let helpers.generate_*_thumbnail raise FileNotFoundError. --- etiquette/helpers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/etiquette/helpers.py b/etiquette/helpers.py index e53ef1d..5db325a 100644 --- a/etiquette/helpers.py +++ b/etiquette/helpers.py @@ -156,6 +156,8 @@ def fit_into_bounds(image_width, image_height, frame_width, frame_height): return (new_width, new_height) def generate_image_thumbnail(filepath, width, height): + if not os.path.isfile(filepath): + raise FileNotFoundError(filepath) image = PIL.Image.open(filepath) (image_width, image_height) = image.size (new_width, new_height) = fit_into_bounds( @@ -183,6 +185,8 @@ def generate_image_thumbnail(filepath, width, height): return image def generate_video_thumbnail(filepath, outfile, width, height, **special): + if not os.path.isfile(filepath): + raise FileNotFoundError(filepath) probe = constants.ffmpeg.probe(filepath) if not probe.video: return False