Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open latest workfile hook #11

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
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
34 changes: 34 additions & 0 deletions client/ayon_equalizer/hooks/pre_add_last_workfile_arg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import os

from ayon_applications import LaunchTypes, PreLaunchHook


class AddLast3DEWorkfileToLaunchArgs(PreLaunchHook):
"""Add last workfile path to launch arguments.

Copied from ayon_core/hooks/pre_add_last_workfile_arg.py.
Checks 'start_last_workfile', if set to False, it will not open last
workfile. This property is set explicitly in Launcher.
"""

# Execute after workfile template copy
order = 10
app_groups = ("equalizer", "sdv_3dequalizer")
johhnry marked this conversation as resolved.
Show resolved Hide resolved
launch_types = LaunchTypes.local
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This must be a set

Suggested change
launch_types = LaunchTypes.local
launch_types = {LaunchTypes.local}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied it from

app_groups = ("equalizer", "sdv_3dequalizer")
so this needs to be changed too?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say so. @antirotor any idea where that sdv_3dequalizer comes from?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it comes from the time where you couldn't have number at the start of the name, so it was prefixed by "sdv" -Science D-Visions". Then it stayed there for compatibility reasons


def execute(self):
if not self.data.get("start_last_workfile"):
self.log.info("It is set to not start last workfile on start.")
return

last_workfile = self.data.get("last_workfile_path")
if not last_workfile:
self.log.warning("Last workfile was not collected.")
return

if not os.path.exists(last_workfile):
self.log.info("Current context does not have any workfile yet.")
return

# Add path to workfile to arguments
self.launch_context.launch_args.extend(["-open", last_workfile])