mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
finally solving issue with ftrack session closed
needed to remove all modules and re-import them on start
This commit is contained in:
parent
23ecee1cf0
commit
13785ca7ad
3 changed files with 36 additions and 32 deletions
|
|
@ -6,7 +6,6 @@ import json
|
|||
from contextlib import contextmanager
|
||||
|
||||
import app_utils
|
||||
reload(app_utils)
|
||||
|
||||
# Fill following constants or set them via environment variable
|
||||
FTRACK_MODULE_PATH = None
|
||||
|
|
@ -14,6 +13,7 @@ FTRACK_API_KEY = None
|
|||
FTRACK_API_USER = None
|
||||
FTRACK_SERVER = None
|
||||
|
||||
|
||||
def import_ftrack_api():
|
||||
try:
|
||||
import ftrack_api
|
||||
|
|
@ -104,7 +104,6 @@ class FtrackComponentCreator:
|
|||
self.videos = [f for f in temp_files if "mov" in f]
|
||||
self.temp_dir = tempdir_path
|
||||
|
||||
|
||||
def get_thumb_path(self, shot_name):
|
||||
# get component files
|
||||
thumb_f = next((f for f in self.thumbnails if shot_name in f), None)
|
||||
|
|
@ -162,7 +161,7 @@ class FtrackComponentCreator:
|
|||
|
||||
# get or create assetversion entity from session
|
||||
assetversion_entity = self._get_assetversion({
|
||||
"version": 1,
|
||||
"version": 0,
|
||||
"asset": asset_entity
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,26 @@
|
|||
from ftrack_lib import (
|
||||
get_ftrack_session,
|
||||
FtrackEntityOperator,
|
||||
FtrackComponentCreator
|
||||
)
|
||||
import app_utils
|
||||
import os
|
||||
from PySide2 import QtWidgets, QtCore
|
||||
|
||||
import uiwidgets
|
||||
import flame
|
||||
|
||||
import app_utils
|
||||
import ftrack_lib
|
||||
reload(ftrack_lib)
|
||||
reload(app_utils)
|
||||
|
||||
def clear_inner_modules():
|
||||
import sys
|
||||
|
||||
if "ftrack_lib" in sys.modules.keys():
|
||||
del sys.modules["ftrack_lib"]
|
||||
print("Ftrack Lib module removed from sys.modules")
|
||||
|
||||
if "app_utils" in sys.modules.keys():
|
||||
del sys.modules["app_utils"]
|
||||
print("app_utils module removed from sys.modules")
|
||||
|
||||
if "uiwidgets" in sys.modules.keys():
|
||||
del sys.modules["uiwidgets"]
|
||||
print("uiwidgets module removed from sys.modules")
|
||||
|
||||
class MainWindow(QtWidgets.QWidget):
|
||||
can_close = True
|
||||
|
||||
def __init__(self, klass, *args, **kwargs):
|
||||
super(MainWindow, self).__init__(*args, **kwargs)
|
||||
|
|
@ -26,7 +31,7 @@ class MainWindow(QtWidgets.QWidget):
|
|||
print("Removing temp data")
|
||||
self.panel_class.clear_temp_data()
|
||||
self.panel_class.close()
|
||||
|
||||
clear_inner_modules()
|
||||
# now the panel can be closed
|
||||
event.accept()
|
||||
|
||||
|
|
@ -65,13 +70,8 @@ class FlameToFtrackPanel(object):
|
|||
|
||||
def __init__(self, selection):
|
||||
print(selection)
|
||||
print(self.processed_components)
|
||||
|
||||
self.session = get_ftrack_session()
|
||||
|
||||
self.processed_components = []
|
||||
print(self.processed_components)
|
||||
|
||||
self.session = ftrack_lib.get_ftrack_session()
|
||||
self.selection = selection
|
||||
self.window = MainWindow(self)
|
||||
# creating ui
|
||||
|
|
@ -225,7 +225,7 @@ class FlameToFtrackPanel(object):
|
|||
cfg_d["create_task_type"], self.task_types.keys(), self.window)
|
||||
|
||||
def _create_project_widget(self):
|
||||
|
||||
import flame
|
||||
# get project name from flame current project
|
||||
self.project_name = flame.project.current_project.name
|
||||
|
||||
|
|
@ -314,9 +314,9 @@ class FlameToFtrackPanel(object):
|
|||
# get resolution from gui inputs
|
||||
fps = self.fps_input.text()
|
||||
|
||||
entity_operator = FtrackEntityOperator(
|
||||
entity_operator = ftrack_lib.FtrackEntityOperator(
|
||||
self.session, self.project_entity)
|
||||
component_creator = FtrackComponentCreator(self.session)
|
||||
component_creator = ftrack_lib.FtrackComponentCreator(self.session)
|
||||
|
||||
if not self.temp_data_dir:
|
||||
self.window.hide()
|
||||
|
|
@ -517,6 +517,7 @@ class FlameToFtrackPanel(object):
|
|||
self.temp_data_dir = None
|
||||
print("All Temp data were destroied ...")
|
||||
|
||||
|
||||
def close(self):
|
||||
self._save_ui_state_to_cfg()
|
||||
self.session.close()
|
||||
|
|
|
|||
|
|
@ -3,15 +3,19 @@ from __future__ import print_function
|
|||
import os
|
||||
import sys
|
||||
|
||||
try:
|
||||
import panel_app
|
||||
reload(panel_app)
|
||||
except ImportError:
|
||||
SCRIPT_DIR = os.path.dirname(__file__)
|
||||
PACKAGE_DIR = os.path.join(SCRIPT_DIR, "modules")
|
||||
sys.path.append(PACKAGE_DIR)
|
||||
SCRIPT_DIR = os.path.dirname(__file__)
|
||||
PACKAGE_DIR = os.path.join(SCRIPT_DIR, "modules")
|
||||
sys.path.append(PACKAGE_DIR)
|
||||
|
||||
|
||||
def flame_panel_executor(selection):
|
||||
if "panel_app" in sys.modules.keys():
|
||||
print("panel_app module is already loaded")
|
||||
del sys.modules["panel_app"]
|
||||
print("panel_app module removed from sys.modules")
|
||||
|
||||
import panel_app
|
||||
panel_app.FlameToFtrackPanel(selection)
|
||||
|
||||
|
||||
def scope_sequence(selection):
|
||||
|
|
@ -27,7 +31,7 @@ def get_media_panel_custom_ui_actions():
|
|||
{
|
||||
"name": "Create Shots",
|
||||
"isVisible": scope_sequence,
|
||||
"execute": panel_app.FlameToFtrackPanel
|
||||
"execute": flame_panel_executor
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue