Merge pull request #3706 from pypeclub/feature/OP-3779_Standalone-publisher-as-module

StandalonePublisher: Define StandalonePublisher as module
This commit is contained in:
Jakub Trllo 2022-08-23 14:38:12 +02:00 committed by GitHub
commit d482df6325
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 63 additions and 67 deletions

View file

@ -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.

View file

@ -0,0 +1,6 @@
from .standalonepublish_module import StandAlonePublishModule
__all__ = (
"StandAlonePublishModule",
)

View file

@ -0,0 +1,57 @@
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.modules.interfaces import ITrayAction, IHostModule
STANDALONEPUBLISH_ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
class StandAlonePublishModule(OpenPypeModule, ITrayAction, IHostModule):
label = "Publish"
name = "standalonepublish_tool"
host_name = "standalonepublisher"
def initialize(self, modules_settings):
self.enabled = modules_settings[self.name]["enabled"]
self.publish_paths = [
os.path.join(STANDALONEPUBLISH_ROOT_DIR, "plugins", "publish")
]
def tray_init(self):
return
def on_action_trigger(self):
self.run_standalone_publisher()
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("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()

View file

@ -1,49 +0,0 @@
import os
import platform
import subprocess
from openpype.lib import get_openpype_execute_args
from openpype.modules import OpenPypeModule
from openpype_interfaces import ITrayAction
class StandAlonePublishAction(OpenPypeModule, ITrayAction):
label = "Publish"
name = "standalonepublish_tool"
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"
)
]
def tray_init(self):
return
def on_action_trigger(self):
self.run_standalone_publisher()
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)

View file

@ -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

View file

@ -47,7 +47,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}
@ -140,12 +139,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