Skip to content

Commit

Permalink
re-FIX #142
Browse files Browse the repository at this point in the history
  • Loading branch information
zitelog committed Oct 31, 2024
1 parent 5ffa18f commit 8c2e058
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions model/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 8c2e058

Please sign in to comment.