From 5cb99e07b65057162bb660286340ea9e5d02af08 Mon Sep 17 00:00:00 2001 From: Nico Jensen Date: Mon, 30 Oct 2023 12:46:08 +0100 Subject: [PATCH] Add Error Handling when upload folder is empty --- PixelfedImporter.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/PixelfedImporter.py b/PixelfedImporter.py index e432213..9384eb2 100644 --- a/PixelfedImporter.py +++ b/PixelfedImporter.py @@ -104,6 +104,8 @@ def createNewPost(access_token, url, ImageID, ImageDescription): def sendImages(Token, url, imagedir, uploadType, deleteFile): files = getImages(imagedir) + if not files: + raise ValueError("No file found.") tags = getTags("tags.txt") tagDescription = "" newFileID = "" @@ -140,5 +142,8 @@ if __name__ == "__main__": imagedir = config.get("image_path") uploadType = config.get("upload_type") deleteFile = config.get("delete_file") - - sendImages(accessToken, url, imagedir, uploadType, deleteFile) \ No newline at end of file + + try: + sendImages(accessToken, url, imagedir, uploadType, deleteFile) + except ValueError as e: + print(f"Error while uploading the image: {e}") \ No newline at end of file