mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
* ApplicationManager can have more granular way how applications are launched * executable is optional to be able create ApplicationLaunchContext * launch context can run prelaunch hooks without launching application * 'get_app_environments_for_context' is using launch context to prepare environments * added 'launch_type' as one of filtering options for LaunchHook * added 'local' launch type filter to existing launch hooks * define 'automated' launch type in remote publish function * modified publish and extract environments cli commands * launch types are only for local by default * fix import * fix launch types of global host data * change order or kwargs * change unreal filter attribute * use set instead of list * removed '__init__' from celaction hooks * use 'CELACTION_ROOT_DIR' in pre setup * use full import from applications
35 lines
1.4 KiB
Python
35 lines
1.4 KiB
Python
import os
|
|
from openpype.lib.applications import PreLaunchHook, LaunchTypes
|
|
|
|
|
|
class LaunchWithTerminal(PreLaunchHook):
|
|
"""Mac specific pre arguments for application.
|
|
|
|
Mac applications should be launched using "open" argument which is internal
|
|
callbacks to open executable. We also add argument "-a" to tell it's
|
|
application open. This is used only for executables ending with ".app". It
|
|
is expected that these executables lead to app packages.
|
|
"""
|
|
order = 1000
|
|
|
|
platforms = {"darwin"}
|
|
launch_types = {LaunchTypes.local}
|
|
|
|
def execute(self):
|
|
executable = str(self.launch_context.executable)
|
|
# Skip executables not ending with ".app" or that are not folder
|
|
if not executable.endswith(".app") or not os.path.isdir(executable):
|
|
return
|
|
|
|
# Check if first argument match executable path
|
|
# - Few applications are not executed directly but through OpenPype
|
|
# process (Photoshop, AfterEffects, Harmony, ...). These should not
|
|
# use `open`.
|
|
if self.launch_context.launch_args[0] != executable:
|
|
return
|
|
|
|
# Tell `open` to pass arguments if there are any
|
|
if len(self.launch_context.launch_args) > 1:
|
|
self.launch_context.launch_args.insert(1, "--args")
|
|
# Prepend open arguments
|
|
self.launch_context.launch_args.insert(0, ["open", "-na"])
|