ftrack server is using ftrack module to get paths to handlers

This commit is contained in:
iLLiCiTiT 2020-12-16 19:11:52 +01:00
parent c240cd813b
commit 52e892f9fc
4 changed files with 14 additions and 66 deletions

View file

@ -1,8 +1,5 @@
from . settings import (
FTRACK_MODULE_DIR,
SERVER_HANDLERS_DIR,
get_ftrack_url_from_settings,
get_server_event_handler_paths,
get_ftrack_event_mongo_info
)
from . import avalon_sync
@ -13,10 +10,7 @@ from .ftrack_action_handler import BaseAction, ServerAction, statics_icon
__all__ = (
"FTRACK_MODULE_DIR",
"SERVER_HANDLERS_DIR",
"get_ftrack_url_from_settings",
"get_server_event_handler_paths",
"get_ftrack_event_mongo_info",
"avalon_sync",

View file

@ -9,9 +9,6 @@ from pype.api import (
log = Logger().get_logger(__name__)
FTRACK_MODULE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SERVER_HANDLERS_DIR = os.path.join(FTRACK_MODULE_DIR, "events")
def get_ftrack_settings():
return get_system_settings()["modules"]["ftrack"]
@ -21,55 +18,6 @@ def get_ftrack_url_from_settings():
return get_ftrack_settings()["ftrack_server"]
def get_server_event_handler_paths():
paths = []
# Environment variable overrides settings
if "FTRACK_EVENTS_PATH" in os.environ:
env_paths = os.environ.get("FTRACK_EVENTS_PATH")
paths.extend(env_paths.split(os.pathsep))
return paths
# Add pype's default dir
paths.append(SERVER_HANDLERS_DIR)
# Add additional paths from settings
paths.extend(
get_ftrack_settings()["ftrack_events_path"]
)
try:
clockify_path = clockify_event_path()
if clockify_path:
paths.append(clockify_path)
except Exception:
log.warning("Clockify paths function failed.", exc_info=True)
# Filter only existing paths
_paths = []
for path in paths:
if os.path.exists(path):
_paths.append(path)
else:
log.warning((
"Registered event handler path is not accessible: {}"
).format(path))
return _paths
def clockify_event_path():
api_key = os.environ.get("CLOCKIFY_API_KEY")
if not api_key:
log.warning("Clockify API key is not set.")
return
workspace_name = os.environ.get("CLOCKIFY_WORKSPACE")
if not workspace_name:
log.warning("Clockify Workspace is not set.")
return
from pype.modules.clockify.constants import CLOCKIFY_FTRACK_SERVER_PATH
return CLOCKIFY_FTRACK_SERVER_PATH
def get_ftrack_event_mongo_info():
ftrack_settings = get_ftrack_settings()
database_name = ftrack_settings["mongo_database_name"]