mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-27 14:22:37 +01:00
added event which triggers syncrhonization of autosync projects
This commit is contained in:
parent
110197a7d4
commit
e17ca875e0
1 changed files with 56 additions and 0 deletions
56
pype/ftrack/events/event_sync_all_auto_sync.py
Normal file
56
pype/ftrack/events/event_sync_all_auto_sync.py
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
from pype.ftrack import BaseEvent
|
||||
|
||||
|
||||
class SyncAllAutoSyncProjects(BaseEvent):
|
||||
def register(self):
|
||||
'''Registers the event, subscribing the discover and launch topics.'''
|
||||
self.session.event_hub.subscribe(
|
||||
'topic=pype.storer.started',
|
||||
self.launch
|
||||
)
|
||||
|
||||
def launch(self, event):
|
||||
session = self.session
|
||||
projects = session.query("Project").all()
|
||||
if not projects:
|
||||
return False
|
||||
|
||||
selections = []
|
||||
for project in projects:
|
||||
if project["status"] != "active":
|
||||
continue
|
||||
|
||||
auto_sync = project["custom_attributes"].get("avalon_auto_sync")
|
||||
if not auto_sync:
|
||||
continue
|
||||
|
||||
selections.append({
|
||||
"entityId": project["id"],
|
||||
"entityType": "show"
|
||||
})
|
||||
|
||||
if not selections:
|
||||
return
|
||||
|
||||
user = session.query(
|
||||
"User where username is \"{}\"".format(session.api_user)
|
||||
).one()
|
||||
user_data = {
|
||||
"username": user["username"],
|
||||
"id": user["id"]
|
||||
}
|
||||
action_name = "sync.to.avalon.server"
|
||||
|
||||
for selection in selections:
|
||||
self.trigger_action(
|
||||
action_name,
|
||||
selection=[selection],
|
||||
user_data=user_data
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def register(session, plugins_presets={}):
|
||||
"""Register plugin. Called when used as an plugin."""
|
||||
SyncAllAutoSyncProjects(session, plugins_presets).register()
|
||||
Loading…
Add table
Add a link
Reference in a new issue