mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
added helper function to determine if ui executable is used
This commit is contained in:
parent
508d4b559e
commit
562730fa65
6 changed files with 63 additions and 40 deletions
|
|
@ -155,6 +155,7 @@ from .path_tools import (
|
|||
|
||||
from .ayon_info import (
|
||||
is_running_from_build,
|
||||
is_using_ui_executable,
|
||||
is_staging_enabled,
|
||||
is_dev_mode_enabled,
|
||||
is_in_tests,
|
||||
|
|
@ -275,6 +276,7 @@ __all__ = [
|
|||
"Logger",
|
||||
|
||||
"is_running_from_build",
|
||||
"is_using_ui_executable",
|
||||
"is_staging_enabled",
|
||||
"is_dev_mode_enabled",
|
||||
"is_in_tests",
|
||||
|
|
|
|||
|
|
@ -10,6 +10,12 @@ from .local_settings import get_local_site_id
|
|||
|
||||
|
||||
def get_ayon_launcher_version():
|
||||
"""Get AYON launcher version.
|
||||
|
||||
Returns:
|
||||
str: Version string.
|
||||
|
||||
"""
|
||||
version_filepath = os.path.join(os.environ["AYON_ROOT"], "version.py")
|
||||
if not os.path.exists(version_filepath):
|
||||
return None
|
||||
|
|
@ -24,8 +30,8 @@ def is_running_from_build():
|
|||
|
||||
Returns:
|
||||
bool: True if running from build.
|
||||
"""
|
||||
|
||||
"""
|
||||
executable_path = os.environ["AYON_EXECUTABLE"]
|
||||
executable_filename = os.path.basename(executable_path)
|
||||
if "python" in executable_filename.lower():
|
||||
|
|
@ -33,6 +39,32 @@ def is_running_from_build():
|
|||
return True
|
||||
|
||||
|
||||
def is_using_ui_executable():
|
||||
"""AYON launcher UI windows executable is used.
|
||||
|
||||
This function make sense only on Windows platform. For other platforms
|
||||
always returns False. False is also returned if process is running from
|
||||
code.
|
||||
|
||||
AYON launcher on windows has 2 executable files. First 'ayon_console.exe'
|
||||
works as 'python.exe' executable, the second 'ayon.exe' works as
|
||||
'pythonw.exe' executable. The difference is way how stdout/stderr is
|
||||
handled (especially when calling subprocess).
|
||||
|
||||
Returns:
|
||||
bool: True if UI executable is used.
|
||||
|
||||
"""
|
||||
if (
|
||||
platform.system().lower() != "windows"
|
||||
or is_running_from_build()
|
||||
):
|
||||
return False
|
||||
executable_path = os.environ["AYON_EXECUTABLE"]
|
||||
executable_filename = os.path.basename(executable_path)
|
||||
return "ayon_console" not in executable_filename
|
||||
|
||||
|
||||
def is_staging_enabled():
|
||||
return os.getenv("AYON_USE_STAGING") == "1"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue