From 568c4a65a08fab3bdf1e7b3dc190eaf86204f531 Mon Sep 17 00:00:00 2001 From: Spitap Date: Thu, 21 Jul 2022 16:51:32 +0200 Subject: [PATCH] fix none-type passed to os.path --- modoboa_installer/scripts/backup.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/modoboa_installer/scripts/backup.py b/modoboa_installer/scripts/backup.py index 588ca99..0dcae30 100644 --- a/modoboa_installer/scripts/backup.py +++ b/modoboa_installer/scripts/backup.py @@ -32,14 +32,17 @@ class Backup(): def preparePath(self): for dir in self.BACKUPDIRECTORY: - os.mkdir(self.destinationPath + dir) + utils.mkdir(self.destinationPath + dir) def validatePath(self, path): """Check basic condition for backup directory""" - - if os.path.isfile(path): - print("Error, you provided a file instead of a directory!") + try: + if os.path.isfile(path): + print("Error, you provided a file instead of a directory!") + return False + except: + print("Provided path is not recognized...") return False if not os.path.exists(path): @@ -69,7 +72,7 @@ class Backup(): def setPath(self): """Setup backup directory""" user_value = None - while (user_value != '' and not self.validatePath(user_value)): + while (user_value != '' and user_value != None and not self.validatePath(user_value)): print("Enter backup path, please provide an empty folder.") print("CTRL+C to cancel") user_value = utils.user_input("-> ")