Skip to content
Open
Changes from all commits
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
53 changes: 50 additions & 3 deletions client/ayon_core/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ def main_cli(ctx, *_args, **_kwargs):
if os.getenv("AYON_HEADLESS_MODE") == "1":
print(ctx.get_help())
sys.exit(0)
else:
ctx.params.pop("project")
ctx.forward(tray)

ctx.params.pop("project")
ctx.forward(tray)
Comment on lines +62 to +64
Copy link
Member

Choose a reason for hiding this comment

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

We should not start tray in headless mode.

Suggested change
ctx.params.pop("project")
ctx.forward(tray)
else:
ctx.params.pop("project")
ctx.forward(tray)

Copy link
Member Author

Choose a reason for hiding this comment

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

if I read this code right - the whole original chunk of code is:

if os.getenv("AYON_HEADLESS_MODE") == "1":
    print(ctx.get_help())
    sys.exit(0)
else:
    ctx.params.pop("project")
    ctx.forward(tray)

you don't need else because of sys.exit()?



@main_cli.command()
Expand Down Expand Up @@ -386,6 +386,53 @@ def main(*args, **kwargs):

_cleanup_project_args()

app_addon = addons_manager.get_enabled_addon("applications")
Copy link
Member

@iLLiCiTiT iLLiCiTiT Nov 11, 2025

Choose a reason for hiding this comment

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

Do you realize that this cli is also used for small subprocesses like extract burnin, ffmpeg user service ocio functionality etc? Some of them are already outputing to parent process. On windows it also doesn't make sense to read output if stdout/stderr is not available at all (is set to None).

I don't think we should do it automatically for all processes TBH. It should be explicit and not enabled by default. Have one function in ayon-core to store the process info that can be easily called.

Copy link
Member

Choose a reason for hiding this comment

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

With that function we should move that logic to ayon-core.


import semver

app_addon_version = semver.Version.parse(app_addon.version).to_tuple()
# Process Manager API is available since 1.2.4
if app_addon is not None and app_addon_version >= (1, 2, 4):
from ayon_applications.process import ProcessManager, ProcessInfo
import tempfile

process_info = ProcessInfo(
name="ayon-cli",
executable=Path(sys.executable),
args=list(sys.argv),
env=dict(os.environ),
pid=os.getpid(),
cwd=os.getcwd(),
)

output_file = None
with tempfile.NamedTemporaryFile(
mode="w", prefix="ayon_ayon-cli_output_",
suffix=".txt",
delete=False,
encoding="utf-8") as temp_file:
output_file = temp_file.name

process_info.output = Path(output_file)

process_manager = ProcessManager()
process_manager.store_process_info(process_info)

with open(output_file, "a", encoding="utf-8") as f:
sys.stdout = sys.stderr = f

try:
main_cli(
prog_name="ayon",
obj={"addons_manager": addons_manager},
args=(sys.argv[1:]),
)
except Exception: # noqa
exc_info = sys.exc_info()
print("!!! AYON crashed:")
traceback.print_exception(*exc_info)
sys.exit(1)

try:
main_cli(
prog_name="ayon",
Expand Down
Loading