Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #967 from pypeclub/bugfix/create_project_structure…
Browse files Browse the repository at this point in the history
…_action

Create project structure action fix multiroot
  • Loading branch information
mkolar authored Feb 3, 2021
2 parents f1350c1 + 9acbb7d commit 6fd147e
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions pype/modules/ftrack/actions/action_create_project_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ def launch(self, session, entities, event):
try:
# Get paths based on presets
basic_paths = self.get_path_items(project_folder_presets)
anatomy = Anatomy(project["full_name"])
self.create_folders(basic_paths, entity, project, anatomy)
self.create_folders(basic_paths, project)
self.create_ftrack_entities(basic_paths, project)

except Exception as exc:
self.log.warning("Creating of structure crashed.", exc_info=True)
session.rollback()
return {
"success": False,
Expand Down Expand Up @@ -219,10 +219,11 @@ def compute_paths(self, basic_paths_items, project_root):
output.append(os.path.normpath(os.path.sep.join(clean_items)))
return output

def create_folders(self, basic_paths, entity, project, anatomy):
def create_folders(self, basic_paths, project):
anatomy = Anatomy(project["full_name"])
roots_paths = []
if isinstance(anatomy.roots, dict):
for root in anatomy.roots:
for root in anatomy.roots.values():
roots_paths.append(root.value)
else:
roots_paths.append(anatomy.roots.value)
Expand All @@ -232,9 +233,14 @@ def create_folders(self, basic_paths, entity, project, anatomy):
full_paths = self.compute_paths(basic_paths, project_root)
# Create folders
for path in full_paths:
if os.path.exists(path):
continue
os.makedirs(path.format(project_root=project_root))
full_path = path.format(project_root=project_root)
if os.path.exists(full_path):
self.log.debug(
"Folder already exists: {}".format(full_path)
)
else:
self.log.debug("Creating folder: {}".format(full_path))
os.makedirs(full_path)


def register(session, plugins_presets={}):
Expand Down

0 comments on commit 6fd147e

Please sign in to comment.