From 405fd3cad52352ff476cc09508184f5d08186607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Sun, 19 Sep 2021 13:41:38 +0200 Subject: [PATCH] checks for nonexistent dirs --- tgbot/kollagen-bot/main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tgbot/kollagen-bot/main.py b/tgbot/kollagen-bot/main.py index 1e6eb72..a9346e2 100644 --- a/tgbot/kollagen-bot/main.py +++ b/tgbot/kollagen-bot/main.py @@ -121,9 +121,13 @@ class KollagenBot: return False directories = [ - os.path.join(self.base_dir or "./", dir) for dir in args.directories + (dir, os.path.join(self.base_dir or "./", dir)) for dir in args.directories ] + for orig_dir, full_path in directories: + if not os.path.exists(full_path): + raise FileNotFoundError(f'"{orig_dir}" does not exist.') + mode = ["-m", args.mode] if args.mode else [] num_images = ["-n", str(args.num_images)] if args.num_images else [] @@ -131,7 +135,7 @@ class KollagenBot: shell_cmd_line = [ self.kollagen_path, "-r", - *directories, + *[full_path for _, full_path in directories], "-w", str(args.width), "-h",