mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +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
|
from contextlib import contextmanager
|
||||||
|
|
||||||
import app_utils
|
import app_utils
|
||||||
reload(app_utils)
|
|
||||||
|
|
||||||
# Fill following constants or set them via environment variable
|
# Fill following constants or set them via environment variable
|
||||||
FTRACK_MODULE_PATH = None
|
FTRACK_MODULE_PATH = None
|
||||||
|
|
@ -14,6 +13,7 @@ FTRACK_API_KEY = None
|
||||||
FTRACK_API_USER = None
|
FTRACK_API_USER = None
|
||||||
FTRACK_SERVER = None
|
FTRACK_SERVER = None
|
||||||
|
|
||||||
|
|
||||||
def import_ftrack_api():
|
def import_ftrack_api():
|
||||||
try:
|
try:
|
||||||
import ftrack_api
|
import ftrack_api
|
||||||
|
|
@ -104,7 +104,6 @@ class FtrackComponentCreator:
|
||||||
self.videos = [f for f in temp_files if "mov" in f]
|
self.videos = [f for f in temp_files if "mov" in f]
|
||||||
self.temp_dir = tempdir_path
|
self.temp_dir = tempdir_path
|
||||||
|
|
||||||
|
|
||||||
def get_thumb_path(self, shot_name):
|
def get_thumb_path(self, shot_name):
|
||||||
# get component files
|
# get component files
|
||||||
thumb_f = next((f for f in self.thumbnails if shot_name in f), None)
|
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
|
# get or create assetversion entity from session
|
||||||
assetversion_entity = self._get_assetversion({
|
assetversion_entity = self._get_assetversion({
|
||||||
"version": 1,
|
"version": 0,
|
||||||
"asset": asset_entity
|
"asset": asset_entity
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,26 @@
|
||||||
from ftrack_lib import (
|
|
||||||
get_ftrack_session,
|
|
||||||
FtrackEntityOperator,
|
|
||||||
FtrackComponentCreator
|
|
||||||
)
|
|
||||||
import app_utils
|
|
||||||
import os
|
import os
|
||||||
from PySide2 import QtWidgets, QtCore
|
from PySide2 import QtWidgets, QtCore
|
||||||
|
|
||||||
import uiwidgets
|
import uiwidgets
|
||||||
import flame
|
import app_utils
|
||||||
|
|
||||||
import ftrack_lib
|
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):
|
class MainWindow(QtWidgets.QWidget):
|
||||||
can_close = True
|
|
||||||
|
|
||||||
def __init__(self, klass, *args, **kwargs):
|
def __init__(self, klass, *args, **kwargs):
|
||||||
super(MainWindow, self).__init__(*args, **kwargs)
|
super(MainWindow, self).__init__(*args, **kwargs)
|
||||||
|
|
@ -26,7 +31,7 @@ class MainWindow(QtWidgets.QWidget):
|
||||||
print("Removing temp data")
|
print("Removing temp data")
|
||||||
self.panel_class.clear_temp_data()
|
self.panel_class.clear_temp_data()
|
||||||
self.panel_class.close()
|
self.panel_class.close()
|
||||||
|
clear_inner_modules()
|
||||||
# now the panel can be closed
|
# now the panel can be closed
|
||||||
event.accept()
|
event.accept()
|
||||||
|
|
||||||
|
|
@ -65,13 +70,8 @@ class FlameToFtrackPanel(object):
|
||||||
|
|
||||||
def __init__(self, selection):
|
def __init__(self, selection):
|
||||||
print(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.selection = selection
|
||||||
self.window = MainWindow(self)
|
self.window = MainWindow(self)
|
||||||
# creating ui
|
# creating ui
|
||||||
|
|
@ -225,7 +225,7 @@ class FlameToFtrackPanel(object):
|
||||||
cfg_d["create_task_type"], self.task_types.keys(), self.window)
|
cfg_d["create_task_type"], self.task_types.keys(), self.window)
|
||||||
|
|
||||||
def _create_project_widget(self):
|
def _create_project_widget(self):
|
||||||
|
import flame
|
||||||
# get project name from flame current project
|
# get project name from flame current project
|
||||||
self.project_name = flame.project.current_project.name
|
self.project_name = flame.project.current_project.name
|
||||||
|
|
||||||
|
|
@ -314,9 +314,9 @@ class FlameToFtrackPanel(object):
|
||||||
# get resolution from gui inputs
|
# get resolution from gui inputs
|
||||||
fps = self.fps_input.text()
|
fps = self.fps_input.text()
|
||||||
|
|
||||||
entity_operator = FtrackEntityOperator(
|
entity_operator = ftrack_lib.FtrackEntityOperator(
|
||||||
self.session, self.project_entity)
|
self.session, self.project_entity)
|
||||||
component_creator = FtrackComponentCreator(self.session)
|
component_creator = ftrack_lib.FtrackComponentCreator(self.session)
|
||||||
|
|
||||||
if not self.temp_data_dir:
|
if not self.temp_data_dir:
|
||||||
self.window.hide()
|
self.window.hide()
|
||||||
|
|
@ -517,6 +517,7 @@ class FlameToFtrackPanel(object):
|
||||||
self.temp_data_dir = None
|
self.temp_data_dir = None
|
||||||
print("All Temp data were destroied ...")
|
print("All Temp data were destroied ...")
|
||||||
|
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self._save_ui_state_to_cfg()
|
self._save_ui_state_to_cfg()
|
||||||
self.session.close()
|
self.session.close()
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,19 @@ from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
try:
|
SCRIPT_DIR = os.path.dirname(__file__)
|
||||||
import panel_app
|
PACKAGE_DIR = os.path.join(SCRIPT_DIR, "modules")
|
||||||
reload(panel_app)
|
sys.path.append(PACKAGE_DIR)
|
||||||
except ImportError:
|
|
||||||
SCRIPT_DIR = os.path.dirname(__file__)
|
|
||||||
PACKAGE_DIR = os.path.join(SCRIPT_DIR, "modules")
|
def flame_panel_executor(selection):
|
||||||
sys.path.append(PACKAGE_DIR)
|
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
|
import panel_app
|
||||||
|
panel_app.FlameToFtrackPanel(selection)
|
||||||
|
|
||||||
|
|
||||||
def scope_sequence(selection):
|
def scope_sequence(selection):
|
||||||
|
|
@ -27,7 +31,7 @@ def get_media_panel_custom_ui_actions():
|
||||||
{
|
{
|
||||||
"name": "Create Shots",
|
"name": "Create Shots",
|
||||||
"isVisible": scope_sequence,
|
"isVisible": scope_sequence,
|
||||||
"execute": panel_app.FlameToFtrackPanel
|
"execute": flame_panel_executor
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue