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

Feature/optional last workfile launch #365

Merged
merged 2 commits into from
Jul 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions pype/modules/ftrack/lib/ftrack_app_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
from pype import lib as pypelib
from pype.api import config, Anatomy
from .ftrack_action_handler import BaseAction
from avalon.api import last_workfile, HOST_WORKFILE_EXTENSIONS
from avalon.api import (
last_workfile, HOST_WORKFILE_EXTENSIONS, should_start_last_workfile
)


class AppAction(BaseAction):
Expand Down Expand Up @@ -142,6 +144,9 @@ def launch(self, session, entities, event):
"""

entity = entities[0]

task_name = entity["name"]

project_name = entity["project"]["full_name"]

database = pypelib.get_avalon_database()
Expand All @@ -164,7 +169,7 @@ def launch(self, session, entities, event):
"name": entity["project"]["full_name"],
"code": entity["project"]["name"]
},
"task": entity["name"],
"task": task_name,
"asset": asset_name,
"app": host_name,
"hierarchy": hierarchy
Expand Down Expand Up @@ -210,14 +215,28 @@ def launch(self, session, entities, event):
prep_env.update({
"AVALON_PROJECT": project_name,
"AVALON_ASSET": asset_name,
"AVALON_TASK": entity["name"],
"AVALON_APP": self.identifier.split("_")[0],
"AVALON_TASK": task_name,
"AVALON_APP": host_name,
"AVALON_APP_NAME": self.identifier,
"AVALON_HIERARCHY": hierarchy,
"AVALON_WORKDIR": workdir
})
if last_workfile_path and os.path.exists(last_workfile_path):

start_last_workfile = should_start_last_workfile(
project_name, host_name, task_name
)
# Store boolean as "0"(False) or "1"(True)
prep_env["AVALON_OPEN_LAST_WORKFILE"] = (
str(int(bool(start_last_workfile)))
)

if (
start_last_workfile
and last_workfile_path
and os.path.exists(last_workfile_path)
):
prep_env["AVALON_LAST_WORKFILE"] = last_workfile_path

prep_env.update(anatomy.roots_obj.root_environments())

# collect all parents from the task
Expand Down