From 1297e0376bf4e921bf16bdb49e962295ff6260b7 Mon Sep 17 00:00:00 2001 From: Marc Michalsky Date: Thu, 2 Sep 2021 16:17:07 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=EF=B8=8F=20create=20tmp=20folder=20if?= =?UTF-8?q?=20it=20does=20not=20exist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/models.py b/models.py index 2d034d3..f978ccd 100644 --- a/models.py +++ b/models.py @@ -41,6 +41,13 @@ class TazDownloader: Downloads a newspaper from dl.taz.de and stores it in /tmp """ + # Check if folder exists + try: + if not os.path.isdir(dir_path): + os.mkdirs(dir_path) + except Exception as e: + raise TazDownloadError(f"Could find or create \"{dir_path}\":\n{e}") + # download taz try: with requests.get(