mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
Merge pull request #1580 from pypeclub/bugfix/1575-mac-application-launch
This commit is contained in:
commit
36752d244c
2 changed files with 58 additions and 5 deletions
34
openpype/hooks/pre_mac_launch.py
Normal file
34
openpype/hooks/pre_mac_launch.py
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
import os
|
||||||
|
from openpype.lib import PreLaunchHook
|
||||||
|
|
||||||
|
|
||||||
|
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"]
|
||||||
|
|
||||||
|
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", "-a"])
|
||||||
|
|
@ -440,7 +440,20 @@ class EnvironmentTool:
|
||||||
|
|
||||||
|
|
||||||
class ApplicationExecutable:
|
class ApplicationExecutable:
|
||||||
|
"""Representation of executable loaded from settings."""
|
||||||
|
|
||||||
def __init__(self, executable):
|
def __init__(self, executable):
|
||||||
|
# On MacOS check if exists path to executable when ends with `.app`
|
||||||
|
# - it is common that path will lead to "/Applications/Blender" but
|
||||||
|
# real path is "/Applications/Blender.app"
|
||||||
|
if (
|
||||||
|
platform.system().lower() == "darwin"
|
||||||
|
and not os.path.exists(executable)
|
||||||
|
):
|
||||||
|
_executable = executable + ".app"
|
||||||
|
if os.path.exists(_executable):
|
||||||
|
executable = _executable
|
||||||
|
|
||||||
self.executable_path = executable
|
self.executable_path = executable
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|
@ -1177,17 +1190,23 @@ def prepare_context_environments(data):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
workdir = get_workdir_with_workdir_data(workdir_data, anatomy)
|
workdir = get_workdir_with_workdir_data(workdir_data, anatomy)
|
||||||
if not os.path.exists(workdir):
|
|
||||||
log.debug(
|
|
||||||
"Creating workdir folder: \"{}\"".format(workdir)
|
|
||||||
)
|
|
||||||
os.makedirs(workdir)
|
|
||||||
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
raise ApplicationLaunchFailed(
|
raise ApplicationLaunchFailed(
|
||||||
"Error in anatomy.format: {}".format(str(exc))
|
"Error in anatomy.format: {}".format(str(exc))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if not os.path.exists(workdir):
|
||||||
|
log.debug(
|
||||||
|
"Creating workdir folder: \"{}\"".format(workdir)
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
os.makedirs(workdir)
|
||||||
|
except Exception as exc:
|
||||||
|
raise ApplicationLaunchFailed(
|
||||||
|
"Couldn't create workdir because: {}".format(str(exc))
|
||||||
|
)
|
||||||
|
|
||||||
context_env = {
|
context_env = {
|
||||||
"AVALON_PROJECT": project_doc["name"],
|
"AVALON_PROJECT": project_doc["name"],
|
||||||
"AVALON_ASSET": asset_doc["name"],
|
"AVALON_ASSET": asset_doc["name"],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue