Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Added endpoint for configured extensions #2221

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions openpype/hosts/webpublisher/webserver_service/webpublish_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from openpype.lib import OpenPypeMongoConnection
from openpype_modules.avalon_apps.rest_api import _RestApiEndpoint
from openpype.lib.plugin_tools import parse_json
from openpype.settings import get_project_settings

from openpype.lib import PypeLogger

Expand All @@ -34,6 +35,8 @@ def json_dump_handler(value):
return value.isoformat()
if isinstance(value, ObjectId):
return str(value)
if isinstance(value, set):
return list(value)
raise TypeError(value)

@classmethod
Expand Down Expand Up @@ -304,3 +307,36 @@ async def get(self, user) -> Response:
body=self.resource.encode(output),
content_type="application/json"
)


class ConfiguredExtensionsEndpoint(_RestApiEndpoint):
"""Returns dict of extensions which have mapping to family.

Returns:
{
"file_exts": [],
"sequence_exts": []
}
"""
async def get(self, project_name=None) -> Response:
sett = get_project_settings(project_name)

configured = {
"file_exts": set(),
"sequence_exts": set(),
# workfiles that could have "Studio Procesing" hardcoded for now
"studio_exts": set(["psd", "psb", "tvpp", "tvp"])
}
collect_conf = sett["webpublisher"]["publish"]["CollectPublishedFiles"]
for _, mapping in collect_conf.get("task_type_to_family", {}).items():
for _family, config in mapping.items():
if config["is_sequence"]:
configured["sequence_exts"].update(config["extensions"])
else:
configured["file_exts"].update(config["extensions"])

return Response(
status=200,
body=self.resource.encode(dict(configured)),
content_type="application/json"
)
10 changes: 9 additions & 1 deletion openpype/hosts/webpublisher/webserver_service/webserver_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
WebpublisherHiearchyEndpoint,
WebpublisherProjectsEndpoint,
BatchStatusEndpoint,
PublishesStatusEndpoint
PublishesStatusEndpoint,
ConfiguredExtensionsEndpoint
)


Expand Down Expand Up @@ -49,6 +50,13 @@ def run_webserver(*args, **kwargs):
hiearchy_endpoint.dispatch
)

configured_ext_endpoint = ConfiguredExtensionsEndpoint(resource)
server_manager.add_route(
"GET",
"/api/webpublish/configured_ext/{project_name}",
configured_ext_endpoint.dispatch
)

# triggers publish
webpublisher_task_publish_endpoint = \
WebpublisherBatchPublishEndpoint(resource)
Expand Down