From ffaa0b7adf6816e12500506f5d77ff4ab1ade3f8 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Mon, 22 Aug 2022 18:22:24 +0200 Subject: [PATCH 1/6] moved standalonepublish action into standalone publish host --- openpype/hosts/standalonepublisher/__init__.py | 6 ++++++ .../standalonepublisher/standalonepublish_module.py} | 0 2 files changed, 6 insertions(+) rename openpype/{modules/standalonepublish_action.py => hosts/standalonepublisher/standalonepublish_module.py} (100%) diff --git a/openpype/hosts/standalonepublisher/__init__.py b/openpype/hosts/standalonepublisher/__init__.py index e69de29bb2..64c6d995f7 100644 --- a/openpype/hosts/standalonepublisher/__init__.py +++ b/openpype/hosts/standalonepublisher/__init__.py @@ -0,0 +1,6 @@ +from standalonepublish_module import StandAlonePublishModule + + +__all__ = ( + "StandAlonePublishModule", +) diff --git a/openpype/modules/standalonepublish_action.py b/openpype/hosts/standalonepublisher/standalonepublish_module.py similarity index 100% rename from openpype/modules/standalonepublish_action.py rename to openpype/hosts/standalonepublisher/standalonepublish_module.py From 8c849670872d1d0be4ad5611e7c21c4d77fff8e1 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Mon, 22 Aug 2022 18:23:20 +0200 Subject: [PATCH 2/6] modified standalone publish action to work also as host module --- .../standalonepublish_module.py | 35 +++++++------------ 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/openpype/hosts/standalonepublisher/standalonepublish_module.py b/openpype/hosts/standalonepublisher/standalonepublish_module.py index ba53ce9b9e..2cd46ce342 100644 --- a/openpype/hosts/standalonepublisher/standalonepublish_module.py +++ b/openpype/hosts/standalonepublisher/standalonepublish_module.py @@ -1,26 +1,26 @@ import os import platform import subprocess + +import click + from openpype.lib import get_openpype_execute_args +from openpype.lib.execute import run_detached_process from openpype.modules import OpenPypeModule -from openpype_interfaces import ITrayAction +from openpype.modules.interfaces import ITrayAction, IHostModule + +STANDALONEPUBLISH_ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) -class StandAlonePublishAction(OpenPypeModule, ITrayAction): +class StandAlonePublishModule(OpenPypeModule, ITrayAction, IHostModule): label = "Publish" name = "standalonepublish_tool" + host_name = "standalonepublisher" def initialize(self, modules_settings): - import openpype self.enabled = modules_settings[self.name]["enabled"] self.publish_paths = [ - os.path.join( - openpype.PACKAGE_DIR, - "hosts", - "standalonepublisher", - "plugins", - "publish" - ) + os.path.join(STANDALONEPUBLISH_ROOT_DIR, "plugins", "publish") ] def tray_init(self): @@ -31,19 +31,10 @@ class StandAlonePublishAction(OpenPypeModule, ITrayAction): def connect_with_modules(self, enabled_modules): """Collect publish paths from other modules.""" + publish_paths = self.manager.collect_plugin_paths()["publish"] self.publish_paths.extend(publish_paths) def run_standalone_publisher(self): - args = get_openpype_execute_args("standalonepublisher") - kwargs = {} - if platform.system().lower() == "darwin": - new_args = ["open", "-na", args.pop(0), "--args"] - new_args.extend(args) - args = new_args - - detached_process = getattr(subprocess, "DETACHED_PROCESS", None) - if detached_process is not None: - kwargs["creationflags"] = detached_process - - subprocess.Popen(args, **kwargs) + args = get_openpype_execute_args("module", self.name, "launch") + run_detached_process(args) From 9db2eb3cc0d85d706e5637ae19bfc4ae6f49f028 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Mon, 22 Aug 2022 18:23:32 +0200 Subject: [PATCH 3/6] added cli commands for standalone publisher --- .../standalonepublish_module.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/openpype/hosts/standalonepublisher/standalonepublish_module.py b/openpype/hosts/standalonepublisher/standalonepublish_module.py index 2cd46ce342..2d0114dee1 100644 --- a/openpype/hosts/standalonepublisher/standalonepublish_module.py +++ b/openpype/hosts/standalonepublisher/standalonepublish_module.py @@ -38,3 +38,22 @@ class StandAlonePublishModule(OpenPypeModule, ITrayAction, IHostModule): def run_standalone_publisher(self): args = get_openpype_execute_args("module", self.name, "launch") run_detached_process(args) + + def cli(self, click_group): + click_group.add_command(cli_main) + + +@click.group( + StandAlonePublishModule.name, + help="StandalonePublisher related commands.") +def cli_main(): + pass + + +@cli_main.command() +def launch(): + """Launch StandalonePublisher tool UI.""" + + from openpype.tools import standalonepublish + + standalonepublish.main() From 6a271aae101d86e33eaffe6571b736d8b0ab8c88 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Mon, 22 Aug 2022 18:25:10 +0200 Subject: [PATCH 4/6] removed standalonepublisher from global cli commands --- openpype/cli.py | 6 ------ openpype/pype_commands.py | 5 ----- website/docs/admin_openpype_commands.md | 7 ------- 3 files changed, 18 deletions(-) diff --git a/openpype/cli.py b/openpype/cli.py index 4b653ac43c..398d1a94c0 100644 --- a/openpype/cli.py +++ b/openpype/cli.py @@ -40,12 +40,6 @@ def settings(dev): PypeCommands().launch_settings_gui(dev) -@main.command() -def standalonepublisher(): - """Show Pype Standalone publisher UI.""" - PypeCommands().launch_standalone_publisher() - - @main.command() def tray(): """Launch pype tray. diff --git a/openpype/pype_commands.py b/openpype/pype_commands.py index a447aa916b..66bf5e9bb4 100644 --- a/openpype/pype_commands.py +++ b/openpype/pype_commands.py @@ -76,11 +76,6 @@ class PypeCommands: import (run_webserver) return run_webserver(*args, **kwargs) - @staticmethod - def launch_standalone_publisher(): - from openpype.tools import standalonepublish - standalonepublish.main() - @staticmethod def launch_traypublisher(): from openpype.tools import traypublisher diff --git a/website/docs/admin_openpype_commands.md b/website/docs/admin_openpype_commands.md index 53fc12410f..8345398e1d 100644 --- a/website/docs/admin_openpype_commands.md +++ b/website/docs/admin_openpype_commands.md @@ -48,7 +48,6 @@ For more information [see here](admin_use.md#run-openpype). | interactive | Start python like interactive console session. | | | projectmanager | Launch Project Manager UI | [📑](#projectmanager-arguments) | | settings | Open Settings UI | [📑](#settings-arguments) | -| standalonepublisher | Open Standalone Publisher UI | [📑](#standalonepublisher-arguments) | --- ### `tray` arguments {#tray-arguments} @@ -159,12 +158,6 @@ openpypeconsole settings ``` --- -### `standalonepublisher` arguments {#standalonepublisher-arguments} -`standalonepublisher` has no command-line arguments. -```shell -openpype_console standalonepublisher -``` - ### `repack-version` arguments {#repack-version-arguments} Takes path to unzipped and possibly modified OpenPype version. Files will be zipped, checksums recalculated and version will be determined by folder name From 986e4325c2379001bf33ca3729e8e9608ce9fe87 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Mon, 22 Aug 2022 18:26:01 +0200 Subject: [PATCH 5/6] fix import --- openpype/hosts/standalonepublisher/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/standalonepublisher/__init__.py b/openpype/hosts/standalonepublisher/__init__.py index 64c6d995f7..394d5be397 100644 --- a/openpype/hosts/standalonepublisher/__init__.py +++ b/openpype/hosts/standalonepublisher/__init__.py @@ -1,4 +1,4 @@ -from standalonepublish_module import StandAlonePublishModule +from .standalonepublish_module import StandAlonePublishModule __all__ = ( From ab1e6c4e3dddacb0726c4eddea078af8fca42ebd Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Mon, 22 Aug 2022 18:30:27 +0200 Subject: [PATCH 6/6] removed unused imports --- openpype/hosts/standalonepublisher/standalonepublish_module.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/openpype/hosts/standalonepublisher/standalonepublish_module.py b/openpype/hosts/standalonepublisher/standalonepublish_module.py index 2d0114dee1..bf8e1d2c23 100644 --- a/openpype/hosts/standalonepublisher/standalonepublish_module.py +++ b/openpype/hosts/standalonepublisher/standalonepublish_module.py @@ -1,6 +1,4 @@ import os -import platform -import subprocess import click