From 71a2dd8a677f6daded58d02192e1ccc9791765ac Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 14 Sep 2021 10:35:40 +0200 Subject: [PATCH] added job of synchronization where can be uploaded traceback --- .../action_sync_to_avalon.py | 34 +++++++++++++++++++ .../action_sync_to_avalon.py | 34 +++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/openpype/modules/default_modules/ftrack/event_handlers_server/action_sync_to_avalon.py b/openpype/modules/default_modules/ftrack/event_handlers_server/action_sync_to_avalon.py index 7f9074907a..9d3dee9e71 100644 --- a/openpype/modules/default_modules/ftrack/event_handlers_server/action_sync_to_avalon.py +++ b/openpype/modules/default_modules/ftrack/event_handlers_server/action_sync_to_avalon.py @@ -1,4 +1,6 @@ import time +import sys +import json import traceback from openpype_modules.ftrack.lib import ServerAction @@ -52,6 +54,20 @@ class SyncToAvalonServer(ServerAction): return False def launch(self, session, in_entities, event): + self.log.debug("{}: Creating job".format(self.label)) + + user_entity = session.query( + "User where id is {}".format(event["source"]["user"]["id"]) + ).one() + job_entity = session.create("Job", { + "user": user_entity, + "status": "running", + "data": json.dumps({ + "description": "Sync to avalon is running..." + }) + }) + session.commit() + project_entity = self.get_project_from_entity(in_entities[0]) project_name = project_entity["full_name"] @@ -62,6 +78,12 @@ class SyncToAvalonServer(ServerAction): self.log.error( "Synchronization failed due to code error", exc_info=True ) + + description = "Sync to avalon Crashed (Download traceback)" + self.add_traceback_to_job( + job_entity, session, sys.exc_info(), description + ) + msg = "An error has happened during synchronization" title = "Synchronization report ({}):".format(project_name) items = [] @@ -69,6 +91,12 @@ class SyncToAvalonServer(ServerAction): "type": "label", "value": "# {}".format(msg) }) + items.append({ + "type": "label", + "value": ( + "

Download report from job for more information.

" + ) + }) report = {} try: @@ -85,6 +113,12 @@ class SyncToAvalonServer(ServerAction): return {"success": True, "message": msg} + job_entity["status"] = "done" + job_entity["data"] = json.dumps({ + "description": "Sync to avalon finished." + }) + session.commit() + return result def synchronization(self, event, project_name): diff --git a/openpype/modules/default_modules/ftrack/event_handlers_user/action_sync_to_avalon.py b/openpype/modules/default_modules/ftrack/event_handlers_user/action_sync_to_avalon.py index 4d030d03e8..7d345771e8 100644 --- a/openpype/modules/default_modules/ftrack/event_handlers_user/action_sync_to_avalon.py +++ b/openpype/modules/default_modules/ftrack/event_handlers_user/action_sync_to_avalon.py @@ -1,4 +1,6 @@ import time +import sys +import json import traceback from openpype_modules.ftrack.lib import BaseAction, statics_icon @@ -63,6 +65,20 @@ class SyncToAvalonLocal(BaseAction): return is_valid def launch(self, session, in_entities, event): + self.log.debug("{}: Creating job".format(self.label)) + + user_entity = session.query( + "User where id is {}".format(event["source"]["user"]["id"]) + ).one() + job_entity = session.create("Job", { + "user": user_entity, + "status": "running", + "data": json.dumps({ + "description": "Sync to avalon is running..." + }) + }) + session.commit() + project_entity = self.get_project_from_entity(in_entities[0]) project_name = project_entity["full_name"] @@ -73,6 +89,12 @@ class SyncToAvalonLocal(BaseAction): self.log.error( "Synchronization failed due to code error", exc_info=True ) + + description = "Sync to avalon Crashed (Download traceback)" + self.add_traceback_to_job( + job_entity, session, sys.exc_info(), description + ) + msg = "An error has happened during synchronization" title = "Synchronization report ({}):".format(project_name) items = [] @@ -80,6 +102,12 @@ class SyncToAvalonLocal(BaseAction): "type": "label", "value": "# {}".format(msg) }) + items.append({ + "type": "label", + "value": ( + "

Download report from job for more information.

" + ) + }) report = {} try: @@ -96,6 +124,12 @@ class SyncToAvalonLocal(BaseAction): return {"success": True, "message": msg} + job_entity["status"] = "done" + job_entity["data"] = json.dumps({ + "description": "Sync to avalon finished." + }) + session.commit() + return result def synchronization(self, event, project_name):