fix none-type passed to os.path

This commit is contained in:
Spitap
2022-07-21 16:51:32 +02:00
parent dc84a79528
commit 568c4a65a0

View File

@@ -32,15 +32,18 @@ class Backup():
def preparePath(self): def preparePath(self):
for dir in self.BACKUPDIRECTORY: for dir in self.BACKUPDIRECTORY:
os.mkdir(self.destinationPath + dir) utils.mkdir(self.destinationPath + dir)
def validatePath(self, path): def validatePath(self, path):
"""Check basic condition for backup directory""" """Check basic condition for backup directory"""
try:
if os.path.isfile(path): if os.path.isfile(path):
print("Error, you provided a file instead of a directory!") print("Error, you provided a file instead of a directory!")
return False return False
except:
print("Provided path is not recognized...")
return False
if not os.path.exists(path): if not os.path.exists(path):
createDir = input(f"\"{path}\" doesn't exists, would you like to create it ? [Y/n]\n").lower() createDir = input(f"\"{path}\" doesn't exists, would you like to create it ? [Y/n]\n").lower()
@@ -69,7 +72,7 @@ class Backup():
def setPath(self): def setPath(self):
"""Setup backup directory""" """Setup backup directory"""
user_value = None 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("Enter backup path, please provide an empty folder.")
print("CTRL+C to cancel") print("CTRL+C to cancel")
user_value = utils.user_input("-> ") user_value = utils.user_input("-> ")