mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 22:02:15 +01:00
converted start method to class methods
This commit is contained in:
parent
16d3b39978
commit
41bb148cae
1 changed files with 25 additions and 5 deletions
|
|
@ -1,4 +1,5 @@
|
|||
from openpype.modules import OpenPypeModule
|
||||
from openpype.api import get_system_settings
|
||||
|
||||
|
||||
class HostsJobServer(OpenPypeModule):
|
||||
|
|
@ -30,16 +31,34 @@ class HostsJobServer(OpenPypeModule):
|
|||
api_path = "{}/api/jobs/{}".format(self._server_url, job_id)
|
||||
return requests.get(api_path)
|
||||
|
||||
def start_server(self, port=None, host=None):
|
||||
@classmethod
|
||||
def get_server_url_from_settings(cls):
|
||||
module_settings = get_system_settings()["modules"]
|
||||
return (
|
||||
module_settings
|
||||
.get("hosts_job_server", {})
|
||||
.get("server_url")
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def start_server(cls, port=None, host=None):
|
||||
from .job_server import main
|
||||
|
||||
return main(port, host)
|
||||
|
||||
def start_worker(self, app_name, server_url=None):
|
||||
@classmethod
|
||||
def start_worker(cls, app_name, server_url=None):
|
||||
import requests
|
||||
from openpype.lib import ApplicationManager
|
||||
|
||||
if server_url is None:
|
||||
server_url = self._server_url
|
||||
server_url = cls.get_server_url_from_settings()
|
||||
|
||||
if not server_url:
|
||||
raise ValueError("Server url is not set.")
|
||||
|
||||
# Validate url
|
||||
requests.get(server_url)
|
||||
|
||||
app_manager = ApplicationManager()
|
||||
app = app_manager.applications.get(app_name)
|
||||
|
|
@ -49,10 +68,11 @@ class HostsJobServer(OpenPypeModule):
|
|||
)
|
||||
|
||||
if app.host_name == "tvpaint":
|
||||
return self._start_tvpaint_worker(app, server_url)
|
||||
return cls._start_tvpaint_worker(app, server_url)
|
||||
raise ValueError("Unknown host \"{}\"".format(app.host_name))
|
||||
|
||||
def _start_tvpaint_worker(self, app, server_url):
|
||||
@classmethod
|
||||
def _start_tvpaint_worker(cls, app, server_url):
|
||||
from .job_workers.tvpaint_worker import main
|
||||
|
||||
executable = app.find_executable()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue