diff --git a/__init__.py b/__init__.py deleted file mode 100644 index b85e02a..0000000 --- a/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from storages import * \ No newline at end of file diff --git a/archivers/base_archiver.py b/archivers/base_archiver.py index 6257aba..dc47273 100644 --- a/archivers/base_archiver.py +++ b/archivers/base_archiver.py @@ -6,6 +6,7 @@ from abc import ABC, abstractmethod from urllib.parse import urlparse from storages import Storage +from utils import mkdir_if_not_exists @dataclass @@ -48,8 +49,7 @@ class Archiver(ABC): thumbnails_folder = filename.split('.')[0] + '/' key_folder = key.split('.')[0] + '/' - if not os.path.exists(thumbnails_folder): - os.mkdir(thumbnails_folder) + mkdir_if_not_exists(thumbnails_folder) fps = 0.5 if duration is not None: diff --git a/auto_archive.py b/auto_archive.py index ba05310..472efd2 100644 --- a/auto_archive.py +++ b/auto_archive.py @@ -8,7 +8,7 @@ from dotenv import load_dotenv import archivers from storages import S3Storage, S3Config -from utils import GWorksheet +from utils import GWorksheet, mkdir_if_not_exists load_dotenv() @@ -124,6 +124,7 @@ def main(): logger.info(f'Opening document {args.sheet}') + mkdir_if_not_exists('tmp') process_sheet(args.sheet) diff --git a/utils/__init__.py b/utils/__init__.py index 482e144..9b58126 100644 --- a/utils/__init__.py +++ b/utils/__init__.py @@ -1,2 +1,3 @@ # we need to explicitly expose the available imports here -from .gworksheet import GWorksheet \ No newline at end of file +from .gworksheet import GWorksheet +from .misc import * \ No newline at end of file diff --git a/utils/misc.py b/utils/misc.py new file mode 100644 index 0000000..e8ef66d --- /dev/null +++ b/utils/misc.py @@ -0,0 +1,5 @@ +import os + +def mkdir_if_not_exists(folder): + if not os.path.exists(folder): + os.mkdir(folder) \ No newline at end of file