From a7f56175d6bbdfc3accba9843f1d322e9405997b Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 25 Jul 2024 15:36:41 +0200 Subject: [PATCH] move some logic from cli_commands.py to cli.py --- client/ayon_core/cli.py | 38 ++++++++++++++++++++------------ client/ayon_core/cli_commands.py | 34 ---------------------------- 2 files changed, 24 insertions(+), 48 deletions(-) diff --git a/client/ayon_core/cli.py b/client/ayon_core/cli.py index 0a9bb2aa9c..acc7dfb6d4 100644 --- a/client/ayon_core/cli.py +++ b/client/ayon_core/cli.py @@ -5,6 +5,7 @@ import sys import code import traceback from pathlib import Path +import warnings import click import acre @@ -116,14 +117,25 @@ def extractenvironments( This function is deprecated and will be removed in future. Please use 'addon applications extractenvironments ...' instead. """ - Commands.extractenvironments( - output_json_path, - project, - asset, - task, - app, - envgroup, - ctx.obj["addons_manager"] + warnings.warn( + ( + "Command 'extractenvironments' is deprecated and will be" + " removed in future. Please use" + " 'addon applications extractenvironments ...' instead." + ), + DeprecationWarning + ) + + addons_manager = ctx.obj["addons_manager"] + applications_addon = addons_manager.get_enabled_addon("applications") + if applications_addon is None: + raise RuntimeError( + "Applications addon is not available or enabled." + ) + + # Please ignore the fact this is using private method + applications_addon._cli_extract_environments( + output_json_path, project, asset, task, app, envgroup ) @@ -170,12 +182,10 @@ def contextselection( Context is project name, folder path and task name. The result is stored into json file which path is passed in first argument. """ - Commands.contextselection( - output_path, - project, - folder, - strict - ) + from ayon_core.tools.context_dialog import main + + main(output_path, project, folder, strict) + @main_cli.command( diff --git a/client/ayon_core/cli_commands.py b/client/ayon_core/cli_commands.py index 8ae1ebb3ba..085dd5bb04 100644 --- a/client/ayon_core/cli_commands.py +++ b/client/ayon_core/cli_commands.py @@ -2,7 +2,6 @@ """Implementation of AYON commands.""" import os import sys -import warnings from typing import Optional, List from ayon_core.addon import AddonsManager @@ -136,36 +135,3 @@ class Commands: log.info("Publish finished.") - @staticmethod - def extractenvironments( - output_json_path, project, asset, task, app, env_group, addons_manager - ): - """Produces json file with environment based on project and app. - - Called by Deadline plugin to propagate environment into render jobs. - """ - warnings.warn( - ( - "Command 'extractenvironments' is deprecated and will be" - " removed in future. Please use " - "'addon applications extractenvironments ...' instead." - ), - DeprecationWarning - ) - - applications_addon = addons_manager.get_enabled_addon("applications") - if applications_addon is None: - raise RuntimeError( - "Applications addon is not available or enabled." - ) - - # Please ignore the fact this is using private method - applications_addon._cli_extract_environments( - output_json_path, project, asset, task, app, env_group - ) - - @staticmethod - def contextselection(output_path, project_name, folder_path, strict): - from ayon_core.tools.context_dialog import main - - main(output_path, project_name, folder_path, strict)