From 8c2e0582bc7b660c53fe3770d2ce89f0b35ec953 Mon Sep 17 00:00:00 2001 From: Fabio Zito Date: Thu, 31 Oct 2024 19:14:46 +0100 Subject: [PATCH] re-FIX #142 --- model/case.py | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/model/case.py b/model/case.py index a4476b2..773c458 100644 --- a/model/case.py +++ b/model/case.py @@ -80,22 +80,34 @@ def __set_logo_bin(self, file_path): return file.read() def create_acquisition_directory(self, directories): - acquisition_type_directory = os.path.join( - os.path.expanduser(directories.get("cases_folder")), - directories.get("case_folder"), - directories.get("acquisition_type_folder"), - ) - acquisition_directory = os.path.join( - acquisition_type_directory, "acquisition_1" + cases_folder = os.path.expanduser(directories.get("cases_folder")) + if not os.path.exists(cases_folder): + os.makedirs(cases_folder) + os.chmod(cases_folder, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) + + case_folder = os.path.join(cases_folder, directories.get("case_folder")) + if not os.path.exists(case_folder): + os.makedirs(case_folder) + os.chmod(case_folder, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) + + acquisition_type_folder = os.path.join( + case_folder, directories.get("acquisition_type_folder") ) + if not os.path.exists(acquisition_type_folder): + os.makedirs(acquisition_type_folder) + os.chmod( + acquisition_type_folder, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO + ) + + acquisition_directory = os.path.join(acquisition_type_folder, "acquisition_1") if os.path.isdir(acquisition_directory): # Get all subdirectories from acquisition directory acquisition_directories = [ d - for d in os.listdir(acquisition_type_directory) - if os.path.isdir(os.path.join(acquisition_type_directory, d)) + for d in os.listdir(acquisition_type_folder) + if os.path.isdir(os.path.join(acquisition_type_folder, d)) ] # get only directories with the right "name". This resolve issue 109 @@ -116,12 +128,10 @@ def create_acquisition_directory(self, directories): # Increment index and create the new content folder acquisition_directory = os.path.join( - acquisition_type_directory, "acquisition_" + str(index + 1) + acquisition_type_folder, "acquisition_" + str(index + 1) ) - os.makedirs(acquisition_directory) os.makedirs(acquisition_directory, exist_ok=True) - os.chmod(acquisition_directory, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) # rwxrwxrwx return acquisition_directory