Webpublisher - removed is_webpublish_enabled as unneeded

run_server gets triggered only for webpublisher, doesn't make sense to double check

Moved webpublish dependent classes under webpublish host
Cleaned up setting
This commit is contained in:
Petr Kalis 2021-08-25 11:09:57 +02:00
parent 5164481b36
commit bcea6fbf0d
5 changed files with 50 additions and 79 deletions

View file

@ -19,7 +19,6 @@ from .webpublish_routes import (
from openpype.api import get_system_settings
# SERVER_URL = "http://172.17.0.1:8079" # machine is not listening on localhost
log = PypeLogger().get_logger("webserver_gui")
@ -32,72 +31,62 @@ def run_webserver(*args, **kwargs):
webserver_module = manager.modules_by_name["webserver"]
webserver_module.create_server_manager()
is_webpublish_enabled = False
webpublish_tool = get_system_settings()["modules"].\
get("webpublish_tool")
resource = RestApiResource(webserver_module.server_manager,
upload_dir=kwargs["upload_dir"],
executable=kwargs["executable"])
projects_endpoint = WebpublisherProjectsEndpoint(resource)
webserver_module.server_manager.add_route(
"GET",
"/api/projects",
projects_endpoint.dispatch
)
if webpublish_tool and webpublish_tool["enabled"]:
is_webpublish_enabled = True
hiearchy_endpoint = WebpublisherHiearchyEndpoint(resource)
webserver_module.server_manager.add_route(
"GET",
"/api/hierarchy/{project_name}",
hiearchy_endpoint.dispatch
)
log.debug("is_webpublish_enabled {}".format(is_webpublish_enabled))
if is_webpublish_enabled:
resource = RestApiResource(webserver_module.server_manager,
upload_dir=kwargs["upload_dir"],
executable=kwargs["executable"])
projects_endpoint = WebpublisherProjectsEndpoint(resource)
webserver_module.server_manager.add_route(
"GET",
"/api/projects",
projects_endpoint.dispatch
)
# triggers publish
webpublisher_task_publish_endpoint = \
WebpublisherBatchPublishEndpoint(resource)
webserver_module.server_manager.add_route(
"POST",
"/api/webpublish/batch",
webpublisher_task_publish_endpoint.dispatch
)
hiearchy_endpoint = WebpublisherHiearchyEndpoint(resource)
webserver_module.server_manager.add_route(
"GET",
"/api/hierarchy/{project_name}",
hiearchy_endpoint.dispatch
)
webpublisher_batch_publish_endpoint = \
WebpublisherTaskPublishEndpoint(resource)
webserver_module.server_manager.add_route(
"POST",
"/api/webpublish/task",
webpublisher_batch_publish_endpoint.dispatch
)
# triggers publish
webpublisher_task_publish_endpoint = \
WebpublisherBatchPublishEndpoint(resource)
webserver_module.server_manager.add_route(
"POST",
"/api/webpublish/batch",
webpublisher_task_publish_endpoint.dispatch
)
# reporting
openpype_resource = OpenPypeRestApiResource()
batch_status_endpoint = BatchStatusEndpoint(openpype_resource)
webserver_module.server_manager.add_route(
"GET",
"/api/batch_status/{batch_id}",
batch_status_endpoint.dispatch
)
webpublisher_batch_publish_endpoint = \
WebpublisherTaskPublishEndpoint(resource)
webserver_module.server_manager.add_route(
"POST",
"/api/webpublish/task",
webpublisher_batch_publish_endpoint.dispatch
)
# reporting
openpype_resource = OpenPypeRestApiResource()
batch_status_endpoint = BatchStatusEndpoint(openpype_resource)
webserver_module.server_manager.add_route(
"GET",
"/api/batch_status/{batch_id}",
batch_status_endpoint.dispatch
)
user_status_endpoint = PublishesStatusEndpoint(openpype_resource)
webserver_module.server_manager.add_route(
"GET",
"/api/publishes/{user}",
user_status_endpoint.dispatch
)
user_status_endpoint = PublishesStatusEndpoint(openpype_resource)
webserver_module.server_manager.add_route(
"GET",
"/api/publishes/{user}",
user_status_endpoint.dispatch
)
webserver_module.start_server()
last_reprocessed = time.time()
while True:
if is_webpublish_enabled:
if time.time() - last_reprocessed > 20:
reprocess_failed(kwargs["upload_dir"])
last_reprocessed = time.time()
if time.time() - last_reprocessed > 20:
reprocess_failed(kwargs["upload_dir"])
last_reprocessed = time.time()
time.sleep(1.0)

View file

@ -42,9 +42,8 @@ class PypeCommands:
@staticmethod
def launch_webpublisher_webservercli(*args, **kwargs):
from openpype.modules.webserver.webserver_cli import (
run_webserver
)
from openpype.hosts.webpublisher.webserver_service.webserver_cli \
import (run_webserver)
return run_webserver(*args, **kwargs)
@staticmethod
@ -53,7 +52,7 @@ class PypeCommands:
standalonepublish.main()
@staticmethod
def publish(paths, targets=None, host=None):
def publish(paths, targets=None):
"""Start headless publishing.
Publish use json from passed paths argument.

View file

@ -167,9 +167,6 @@
"standalonepublish_tool": {
"enabled": true
},
"webpublish_tool": {
"enabled": false
},
"project_manager": {
"enabled": true
},

View file

@ -197,20 +197,6 @@
}
]
},
{
"type": "dict",
"key": "webpublish_tool",
"label": "Web Publish",
"collapsible": true,
"checkbox_key": "enabled",
"children": [
{
"type": "boolean",
"key": "enabled",
"label": "Enabled"
}
]
},
{
"type": "dict",
"key": "project_manager",