Ayon_console: openpype.lib.applications.ApplicationNotFound: Application was not found

Hi all,

I am trying to build a custom Qt tool which uses the ayon_console.exe underneath on Windows to launch software with the correct Ayon context and all addons and settings same way we would through the GUI.

Am getting the below error

openpype.lib.applications.ApplicationNotFound: Application "C:\Program Files\Nuke14.1v4\Nuke14.1.exe" was not found.

I am using the following command

ayon_console extractenvironments env_ext.json --project XMB --asset 122X_DDX_1015 --task comp --app "C:\Program Files\Nuke14.1v4\Nuke14.1.exe"

–asset argument is a shot number. I have tried all variations of the --app argument, i.e., nuke, nuke14.1, Nuke14.1, 14.1. Where does it take this value from. Even checked Studio Settings>Applications on the server.

Not sure if I am making any other mistake.

Any help appreciated.

Thank you

The app argument is the full app name from the settings, that is the application group and its variant, so would be along the lines of nuke/15-0

So that’s the application group nuke and the name of the variant 15-0 joined by /.

What in the current launcher design makes you want to design your own Qt launcher regardless of it?

From a code perspective you could also just use the AYON apis and libraries. Some of the logic here may help you out how to build up the environment and retrieve the executable to run.

@BigRoy Thanks for the response.

Currently, the launcher shows shows all folders and their corresponding tasks. Looking for a way to filter current user’s tasks. Was looking to develop a ‘My Tasks’ Qt and add to the Ayon tray. Is there any existing way to accomplish this?
Thank you.

@BigRoy Now it detects the app, however the commands just executes without anything happening

Correct - that specific command writes out a .json file of the environment the application should need when running.

I think you’re instead looking for maybe the launch CLI? See also here.

But, even better, you might be right on time because look here: Add support in Launcher to filter out folders and tasks by assignment by fabiaserra · Pull Request #622 · ynput/ayon-core · GitHub

2 Likes

@BigRoy Thank you. This is very helpful. The linked PR is exactly what I am looking for. Thank you

@BigRoy Could you share some examples of how to use the cli. Can’t find the entry point for it. My use case is just to launch in a specified context same as in the GUI.

Thank you

I asked this some time ago on Discord here where I got linked this PR that had some “testing” examples that used a CLI of Ayon addon.

Unfortunately I do not have specific examples for your launch use case, but maybe @mustafa_jafar has some around or can fire one up. :fire:

2 Likes

Hey,
As far as I know, you can create a tray addon where you can add two things:

  1. A button in Tray menu that shows your launcher window which runs the launch logic in turn.
  2. A CLI action that runs the launch logic.

Here’s an example for them, you can use GitHub - ynput/example-studio-addon and replace the content of addon.py with the following code.

Afterwards, you are free to run python create_package.py and upload addon zip to your server and see it work in action.

import os
from ayon_core.addon import (
    click_wrap,
    AYONAddon,
    IPluginPaths,
    ITrayAddon
)

MY_STUDIO_ADDON_ROOT = os.path.dirname(os.path.abspath(__file__))
ADDON_NAME = "my_studio_addon"
ADDON_LABEL = "My Studio Addon"

class MyStudioAddon(AYONAddon, IPluginPaths, ITrayAddon):
    name = ADDON_NAME
    label = ADDON_LABEL

    def initialize(self, settings):
        """Initialization of module."""
        self.enabled = True
        self._my_dialog = None


    def get_plugin_paths(self):
        return {
            "publish": [
                os.path.join(MY_STUDIO_ADDON_ROOT, "plugins", "publish")
            ]
        }

    # ITrayAddon
    def tray_init(self):
        """Tray init."""
        pass

    def tray_start(self):
        """Tray start."""
        pass

    def tray_exit(self):
        """Tray exit."""
        return

    def _get_my_dialog(self):
        if self._my_dialog is None:
            from .widgets.my_widgets import MyDialog

            self._my_dialog = MyDialog()

        return self._my_dialog

    def show_my_dialog(self):
        """Show dialog to My Dialog."""

        # Make sure dialog is created
        dialog = self._get_my_dialog()

        # Show dialog
        dialog.open()

           # Definition of Tray menu

    def tray_menu(self, tray_menu):
        # Menu for Tray App
        from qtpy import QtWidgets

        # Actions
        action_show_my_dialog = QtWidgets.QAction("My Launcher", tray_menu)
        action_show_my_dialog.triggered.connect(self.show_my_dialog)
        tray_menu.addAction(action_show_my_dialog)

    # Add CLI
    def cli(self, click_group):
        click_group.add_command(cli_main.to_click_obj())


@click_wrap.group(
    MyStudioAddon.name,
    help="MyStudio Addon related commands.")
def cli_main():
    pass

@cli_main.command()
@click_wrap.option(
    "--app",
    help="App to launch",
    type=str,
    required=True
)
def launch(app):
    print("App to launch {}!".format(app))
    # add your launch logic.

Results:

  1. A button in Tray menu
    image
  2. A CLI action…
    >>> ../ayon-launcher/tools/ayon_console.bat --use-dev addon my_studio_addon launch --app my_app
    >>> App to launch my_app!
    

And god, I love AYON dev so much. I was able to change the code without uploading it to AYON.

2 Likes