mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
current sync to avalon will trigger sync to avalon action on checked auto-sync
This commit is contained in:
parent
4201ba173d
commit
aeaef2fa02
1 changed files with 38 additions and 2 deletions
|
|
@ -1,4 +1,3 @@
|
|||
from pype.vendor import ftrack_api
|
||||
from pype.ftrack import BaseEvent, lib
|
||||
|
||||
|
||||
|
|
@ -31,6 +30,42 @@ class SyncToAvalon(BaseEvent):
|
|||
ft_project = session.get(base_proj['type'], base_proj['id'])
|
||||
break
|
||||
|
||||
for ent_info in event['data']['entities']:
|
||||
# filter project
|
||||
if ent_info.get("entityType") != "show":
|
||||
continue
|
||||
|
||||
if ent_info.get("action") != "update":
|
||||
continue
|
||||
|
||||
changes = ent_info.get("changes") or {}
|
||||
if 'avalon_auto_sync' not in changes:
|
||||
continue
|
||||
|
||||
auto_sync = changes['avalon_auto_sync']["new"]
|
||||
if auto_sync == "1":
|
||||
# Trigger sync to avalon action if auto sync was turned on
|
||||
self.log.debug((
|
||||
"Auto sync was turned on for project <{}>."
|
||||
" Triggering syncToAvalon action."
|
||||
).format(ft_project["full_name"]))
|
||||
selection = [{
|
||||
"entityId": ft_project["id"],
|
||||
"entityType": "show"
|
||||
}]
|
||||
# Stop event so sync hierarchical won't be affected
|
||||
# - other event should not be affected since auto-sync
|
||||
# is in all cases single data event
|
||||
event.stop()
|
||||
# Trigger action
|
||||
self.trigger_action(
|
||||
action_name="sync.to.avalon.server",
|
||||
event=event,
|
||||
selection=selection
|
||||
)
|
||||
# Exit for both cases
|
||||
return True
|
||||
|
||||
# check if project is set to auto-sync
|
||||
if (
|
||||
ft_project is None or
|
||||
|
|
@ -101,7 +136,8 @@ class SyncToAvalon(BaseEvent):
|
|||
avalon_project = result['project']
|
||||
|
||||
except Exception as e:
|
||||
session.rollback() # reset session to clear it
|
||||
# reset session to clear it
|
||||
session.rollback()
|
||||
|
||||
message = str(e)
|
||||
title = 'Hey You! Unknown Error has been raised! (*look below*)'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue