mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
added helper function to return linux app launcher arguments
This commit is contained in:
parent
f1b158e7e5
commit
3e096f41be
2 changed files with 46 additions and 2 deletions
|
|
@ -25,6 +25,7 @@ from .env_tools import (
|
|||
from .terminal import Terminal
|
||||
from .execute import (
|
||||
get_pype_execute_args,
|
||||
get_linux_launcher_args,
|
||||
execute,
|
||||
run_subprocess,
|
||||
path_to_subprocess_arg,
|
||||
|
|
@ -174,6 +175,7 @@ terminal = Terminal
|
|||
|
||||
__all__ = [
|
||||
"get_pype_execute_args",
|
||||
"get_linux_launcher_args",
|
||||
"execute",
|
||||
"run_subprocess",
|
||||
"path_to_subprocess_arg",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import os
|
||||
import shlex
|
||||
import subprocess
|
||||
import platform
|
||||
import distutils.spawn
|
||||
|
||||
from .log import PypeLogger as Logger
|
||||
|
||||
|
|
@ -175,3 +174,46 @@ def get_pype_execute_args(*args):
|
|||
pype_args.extend(args)
|
||||
|
||||
return pype_args
|
||||
|
||||
|
||||
def get_linux_launcher_args(*args):
|
||||
"""Path to application mid process executable.
|
||||
|
||||
This function should be able as arguments are different when used
|
||||
from code and build.
|
||||
|
||||
It is possible that this function is used in OpenPype build which does
|
||||
not have yet the new executable. In that case 'None' is returned.
|
||||
|
||||
Args:
|
||||
args (iterable): List of additional arguments added after executable
|
||||
argument.
|
||||
|
||||
Returns:
|
||||
list: Executables with possible positional argument to script when
|
||||
called from code.
|
||||
"""
|
||||
filename = "linux_app_launcher"
|
||||
openpype_executable = os.environ["OPENPYPE_EXECUTABLE"]
|
||||
|
||||
executable_filename = os.path.basename(openpype_executable)
|
||||
if "python" in executable_filename.lower():
|
||||
script_path = os.path.join(
|
||||
os.environ["OPENPYPE_ROOT"],
|
||||
"{}.py".format(filename)
|
||||
)
|
||||
launch_args = [openpype_executable, script_path]
|
||||
else:
|
||||
new_executable = os.path.join(
|
||||
os.path.dirname(openpype_executable),
|
||||
filename
|
||||
)
|
||||
executable_path = distutils.spawn.find_executable(new_executable)
|
||||
if executable_path is None:
|
||||
return None
|
||||
launch_args = [executable_path]
|
||||
|
||||
if args:
|
||||
launch_args.extend(args)
|
||||
|
||||
return launch_args
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue