mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
muster has same rest api methods as before but changed POST for show widget to GET
This commit is contained in:
parent
5c3465ddeb
commit
5252bb006f
5 changed files with 39 additions and 8 deletions
|
|
@ -274,9 +274,9 @@ class CreateRender(plugin.Creator):
|
|||
# authentication token expired so we need to login to Muster
|
||||
# again to get it. We use Pype API call to show login window.
|
||||
api_url = "{}/muster/show_login".format(
|
||||
os.environ["PYPE_REST_API_URL"])
|
||||
os.environ["PYPE_WEBSERVER_URL"])
|
||||
self.log.debug(api_url)
|
||||
login_response = self._requests_post(api_url, timeout=1)
|
||||
login_response = self._requests_get(api_url, timeout=1)
|
||||
if login_response.status_code != 200:
|
||||
self.log.error("Cannot show login form to Muster")
|
||||
raise Exception("Cannot show login form to Muster")
|
||||
|
|
|
|||
|
|
@ -191,9 +191,9 @@ class CreateVRayScene(plugin.Creator):
|
|||
# authentication token expired so we need to login to Muster
|
||||
# again to get it. We use Pype API call to show login window.
|
||||
api_url = "{}/muster/show_login".format(
|
||||
os.environ["PYPE_REST_API_URL"])
|
||||
os.environ["PYPE_WEBSERVER_URL"])
|
||||
self.log.debug(api_url)
|
||||
login_response = self._requests_post(api_url, timeout=1)
|
||||
login_response = self._requests_get(api_url, timeout=1)
|
||||
if login_response.status_code != 200:
|
||||
self.log.error("Cannot show login form to Muster")
|
||||
raise Exception("Cannot show login form to Muster")
|
||||
|
|
|
|||
|
|
@ -85,9 +85,9 @@ class ValidateMusterConnection(pyblish.api.ContextPlugin):
|
|||
Renew authentication token by logging into Muster
|
||||
"""
|
||||
api_url = "{}/muster/show_login".format(
|
||||
os.environ["PYPE_REST_API_URL"])
|
||||
os.environ["PYPE_WEBSERVER_URL"])
|
||||
cls.log.debug(api_url)
|
||||
response = cls._requests_post(api_url, timeout=1)
|
||||
response = cls._requests_get(api_url, timeout=1)
|
||||
if response.status_code != 200:
|
||||
cls.log.error('Cannot show login form to Muster')
|
||||
raise Exception('Cannot show login form to Muster')
|
||||
|
|
|
|||
|
|
@ -4,11 +4,12 @@ import appdirs
|
|||
import requests
|
||||
from .. import (
|
||||
PypeModule,
|
||||
ITrayModule
|
||||
ITrayModule,
|
||||
IWebServerRoutes
|
||||
)
|
||||
|
||||
|
||||
class MusterModule(PypeModule, ITrayModule):
|
||||
class MusterModule(PypeModule, ITrayModule, IWebServerRoutes):
|
||||
"""
|
||||
Module handling Muster Render credentials. This will display dialog
|
||||
asking for user credentials for Muster if not already specified.
|
||||
|
|
@ -31,6 +32,7 @@ class MusterModule(PypeModule, ITrayModule):
|
|||
# Tray attributes
|
||||
self.widget_login = None
|
||||
self.action_show_login = None
|
||||
self.rest_api_obj = None
|
||||
|
||||
def get_global_environments(self):
|
||||
return {
|
||||
|
|
@ -74,6 +76,13 @@ class MusterModule(PypeModule, ITrayModule):
|
|||
|
||||
parent.addMenu(menu)
|
||||
|
||||
def webserver_initialization(self, server_manager):
|
||||
"""Implementation of IWebServerRoutes interface."""
|
||||
if self.tray_initialized:
|
||||
from .rest_api import MusterModuleRestApi
|
||||
|
||||
self.rest_api_obj = MusterModuleRestApi(self, server_manager)
|
||||
|
||||
def load_credentials(self):
|
||||
"""
|
||||
Get credentials from JSON file
|
||||
|
|
|
|||
22
pype/modules/muster/rest_api.py
Normal file
22
pype/modules/muster/rest_api.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
from aiohttp.web_response import Response
|
||||
|
||||
|
||||
class MusterModuleRestApi:
|
||||
def __init__(self, user_module, server_manager):
|
||||
self.module = user_module
|
||||
self.server_manager = server_manager
|
||||
|
||||
self.prefix = "/muster"
|
||||
|
||||
self.register()
|
||||
|
||||
def register(self):
|
||||
self.server_manager.add_route(
|
||||
"GET",
|
||||
self.prefix + "/show_login",
|
||||
self.show_login_widget
|
||||
)
|
||||
|
||||
async def show_login_widget(self, request):
|
||||
self.module.action_show_login.trigger()
|
||||
return Response(status=200)
|
||||
Loading…
Add table
Add a link
Reference in a new issue