Merge pull request #3705 from pypeclub/feature/OP-3780_Traypublisher-as-module

TrayPublisher: Define TrayPublisher as module
This commit is contained in:
Jakub Trllo 2022-08-22 18:32:16 +02:00 committed by GitHub
commit 286407b421
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 18 deletions

View file

@ -46,12 +46,6 @@ def standalonepublisher():
PypeCommands().launch_standalone_publisher()
@main.command()
def traypublisher():
"""Show new OpenPype Standalone publisher UI."""
PypeCommands().launch_traypublisher()
@main.command()
def tray():
"""Launch pype tray.

View file

@ -0,0 +1,6 @@
from .module import TrayPublishModule
__all__ = (
"TrayPublishModule",
)

View file

@ -1,25 +1,24 @@
import os
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
TRAYPUBLISH_ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
class TrayPublishAction(OpenPypeModule, ITrayAction):
class TrayPublishModule(OpenPypeModule, IHostModule, ITrayAction):
label = "New Publish (beta)"
name = "traypublish_tool"
host_name = "traypublish"
def initialize(self, modules_settings):
import openpype
self.enabled = True
self.publish_paths = [
os.path.join(
openpype.PACKAGE_DIR,
"hosts",
"traypublisher",
"plugins",
"publish"
)
os.path.join(TRAYPUBLISH_ROOT_DIR, "plugins", "publish")
]
self._experimental_tools = None
@ -29,7 +28,7 @@ class TrayPublishAction(OpenPypeModule, ITrayAction):
self._experimental_tools = ExperimentalTools()
def tray_menu(self, *args, **kwargs):
super(TrayPublishAction, self).tray_menu(*args, **kwargs)
super(TrayPublishModule, self).tray_menu(*args, **kwargs)
traypublisher = self._experimental_tools.get("traypublisher")
visible = False
if traypublisher and traypublisher.enabled:
@ -45,5 +44,24 @@ class TrayPublishAction(OpenPypeModule, ITrayAction):
self.publish_paths.extend(publish_paths)
def run_traypublisher(self):
args = get_openpype_execute_args("traypublisher")
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(TrayPublishModule.name, help="TrayPublisher related commands.")
def cli_main():
pass
@cli_main.command()
def launch():
"""Launch TrayPublish tool UI."""
from openpype.tools import traypublisher
traypublisher.main()