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

TVPaint: Option to stop timer on application exit. #1887

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
17 changes: 17 additions & 0 deletions openpype/hosts/tvpaint/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import os
import logging

import requests

import avalon.api
import pyblish.api
from avalon.tvpaint import pipeline
from avalon.tvpaint.communication_server import register_localization_file
from .lib import set_context_settings

from openpype.hosts import tvpaint
from openpype.api import get_current_project_settings

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -51,6 +54,19 @@ def initial_launch():
set_context_settings()


def application_exit():
data = get_current_project_settings()
stop_timer = data["tvpaint"]["stop_timer_on_application_exit"]

if not stop_timer:
return

# Stop application timer.
webserver_url = os.environ.get("OPENPYPE_WEBSERVER_URL")
rest_api_url = "{}/timers_manager/stop_timer".format(webserver_url)
requests.post(rest_api_url)


def install():
log.info("OpenPype - Installing TVPaint integration")
localization_file = os.path.join(HOST_DIR, "resources", "avalon.loc")
Expand All @@ -67,6 +83,7 @@ def install():
pyblish.api.register_callback("instanceToggled", on_instance_toggle)

avalon.api.on("application.launched", initial_launch)
avalon.api.on("application.exit", application_exit)


def uninstall():
Expand Down
1 change: 1 addition & 0 deletions openpype/settings/defaults/project_settings/tvpaint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"stop_timer_on_application_exit": false,
"publish": {
"ExtractSequence": {
"review_bg": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
"label": "TVPaint",
"is_file": true,
"children": [
{
"type": "boolean",
"key": "stop_timer_on_application_exit",
"label": "Stop timer on application exit"
},
{
"type": "dict",
"collapsible": true,
Expand Down