mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
moved start and stop plugins into timers manager
This commit is contained in:
parent
29239178cb
commit
70bcd6bf90
4 changed files with 66 additions and 31 deletions
|
|
@ -0,0 +1,39 @@
|
|||
"""
|
||||
Requires:
|
||||
context -> system_settings
|
||||
context -> openPypeModules
|
||||
"""
|
||||
|
||||
import pyblish.api
|
||||
|
||||
from openpype.pipeline import legacy_io
|
||||
|
||||
|
||||
class StartTimer(pyblish.api.ContextPlugin):
|
||||
label = "Start Timer"
|
||||
order = pyblish.api.IntegratorOrder + 1
|
||||
hosts = ["*"]
|
||||
|
||||
def process(self, context):
|
||||
timers_manager = context.data["openPypeModules"]["timers_manager"]
|
||||
if not timers_manager.enabled:
|
||||
self.log.debug("TimersManager is disabled")
|
||||
return
|
||||
|
||||
modules_settings = context.data["system_settings"]["modules"]
|
||||
if not modules_settings["timers_manager"]["disregard_publishing"]:
|
||||
self.log.debug("Publish is not affecting running timers.")
|
||||
return
|
||||
|
||||
project_name = legacy_io.active_project()
|
||||
asset_name = legacy_io.Session.get("AVALON_ASSET")
|
||||
task_name = legacy_io.Session.get("AVALON_TASK")
|
||||
if not project_name or not asset_name or not task_name:
|
||||
self.log.info((
|
||||
"Current context does not contain all"
|
||||
" required information to start a timer."
|
||||
))
|
||||
return
|
||||
timers_manager.start_timer_with_webserver(
|
||||
project_name, asset_name, task_name, self.log
|
||||
)
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
"""
|
||||
Requires:
|
||||
context -> system_settings
|
||||
context -> openPypeModules
|
||||
"""
|
||||
|
||||
|
||||
import pyblish.api
|
||||
|
||||
|
||||
class StopTimer(pyblish.api.ContextPlugin):
|
||||
label = "Stop Timer"
|
||||
order = pyblish.api.ExtractorOrder - 0.49
|
||||
hosts = ["*"]
|
||||
|
||||
def process(self, context):
|
||||
timers_manager = context.data["openPypeModules"]["timers_manager"]
|
||||
if not timers_manager.enabled:
|
||||
self.log.debug("TimersManager is disabled")
|
||||
return
|
||||
|
||||
modules_settings = context.data["system_settings"]["modules"]
|
||||
if not modules_settings["timers_manager"]["disregard_publishing"]:
|
||||
self.log.debug("Publish is not affecting running timers.")
|
||||
return
|
||||
|
||||
timers_manager.stop_timer_with_webserver(self.log)
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
import pyblish.api
|
||||
|
||||
from openpype.lib import change_timer_to_current_context
|
||||
|
||||
|
||||
class StartTimer(pyblish.api.ContextPlugin):
|
||||
label = "Start Timer"
|
||||
order = pyblish.api.IntegratorOrder + 1
|
||||
hosts = ["*"]
|
||||
|
||||
def process(self, context):
|
||||
modules_settings = context.data["system_settings"]["modules"]
|
||||
if modules_settings["timers_manager"]["disregard_publishing"]:
|
||||
change_timer_to_current_context()
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
import os
|
||||
import requests
|
||||
|
||||
import pyblish.api
|
||||
|
||||
|
||||
class StopTimer(pyblish.api.ContextPlugin):
|
||||
label = "Stop Timer"
|
||||
order = pyblish.api.ExtractorOrder - 0.49
|
||||
hosts = ["*"]
|
||||
|
||||
def process(self, context):
|
||||
modules_settings = context.data["system_settings"]["modules"]
|
||||
if modules_settings["timers_manager"]["disregard_publishing"]:
|
||||
webserver_url = os.environ.get("OPENPYPE_WEBSERVER_URL")
|
||||
rest_api_url = "{}/timers_manager/stop_timer".format(webserver_url)
|
||||
requests.post(rest_api_url)
|
||||
Loading…
Add table
Add a link
Reference in a new issue