diff --git a/pype/ftrack/actions/action_attributes_remapper.py b/pype/ftrack/actions/action_attributes_remapper.py index 759b5765e5..a0393ece40 100644 --- a/pype/ftrack/actions/action_attributes_remapper.py +++ b/pype/ftrack/actions/action_attributes_remapper.py @@ -281,7 +281,4 @@ class AttributesRemapper(BaseAction): def register(session, plugins_presets={}): '''Register plugin. Called when used as an plugin.''' - if not isinstance(session, ftrack_api.session.Session): - return - AttributesRemapper(session, plugins_presets).register() diff --git a/pype/ftrack/actions/action_client_review_sort.py b/pype/ftrack/actions/action_client_review_sort.py index 6a659ce5e3..91926c2874 100644 --- a/pype/ftrack/actions/action_client_review_sort.py +++ b/pype/ftrack/actions/action_client_review_sort.py @@ -55,11 +55,8 @@ class ClientReviewSort(BaseAction): def register(session, plugins_presets={}): '''Register action. Called when used as an event plugin.''' - if not isinstance(session, ftrack_api.session.Session): - return - action_handler = ClientReviewSort(session, plugins_presets) - action_handler.register() + ClientReviewSort(session, plugins_presets).register() def main(arguments=None): diff --git a/pype/ftrack/actions/action_component_open.py b/pype/ftrack/actions/action_component_open.py index 33f4d38890..98d773dba6 100644 --- a/pype/ftrack/actions/action_component_open.py +++ b/pype/ftrack/actions/action_component_open.py @@ -68,12 +68,6 @@ class ComponentOpen(BaseAction): def register(session, plugins_presets={}): '''Register action. Called when used as an event plugin.''' - # Validate that session is an instance of ftrack_api.Session. If not, - # assume that register is being called from an old or incompatible API and - # return without doing anything. - if not isinstance(session, ftrack_api.session.Session): - return - ComponentOpen(session, plugins_presets).register() diff --git a/pype/ftrack/actions/action_create_cust_attrs.py b/pype/ftrack/actions/action_create_cust_attrs.py index 47a6bb5d5f..ac6dcb0fd7 100644 --- a/pype/ftrack/actions/action_create_cust_attrs.py +++ b/pype/ftrack/actions/action_create_cust_attrs.py @@ -572,12 +572,6 @@ class CustomAttributes(BaseAction): def register(session, plugins_presets={}): '''Register plugin. Called when used as an plugin.''' - # Validate that session is an instance of ftrack_api.Session. If not, - # assume that register is being called from an old or incompatible API and - # return without doing anything. - if not isinstance(session, ftrack_api.session.Session): - return - CustomAttributes(session, plugins_presets).register() diff --git a/pype/ftrack/actions/action_create_folders.py b/pype/ftrack/actions/action_create_folders.py index 269316e052..44e9741bab 100644 --- a/pype/ftrack/actions/action_create_folders.py +++ b/pype/ftrack/actions/action_create_folders.py @@ -327,9 +327,6 @@ class PartialDict(dict): def register(session, plugins_presets={}): '''Register plugin. Called when used as an plugin.''' - if not isinstance(session, ftrack_api.session.Session): - return - CreateFolders(session, plugins_presets).register() diff --git a/pype/ftrack/actions/action_create_project_structure.py b/pype/ftrack/actions/action_create_project_structure.py index 74d458b5f8..c39c717b11 100644 --- a/pype/ftrack/actions/action_create_project_structure.py +++ b/pype/ftrack/actions/action_create_project_structure.py @@ -198,9 +198,6 @@ class CreateProjectFolders(BaseAction): def register(session, plugins_presets={}): '''Register plugin. Called when used as an plugin.''' - if not isinstance(session, ftrack_api.session.Session): - return - CreateProjectFolders(session, plugins_presets).register() diff --git a/pype/ftrack/actions/action_cust_attr_doctor.py b/pype/ftrack/actions/action_cust_attr_doctor.py index af5fe2dc4a..0469b3a1e6 100644 --- a/pype/ftrack/actions/action_cust_attr_doctor.py +++ b/pype/ftrack/actions/action_cust_attr_doctor.py @@ -9,7 +9,7 @@ from pype.ftrack import BaseAction class CustomAttributeDoctor(BaseAction): - + ignore_me = True #: Action identifier. identifier = 'custom.attributes.doctor' @@ -294,9 +294,6 @@ class CustomAttributeDoctor(BaseAction): def register(session, plugins_presets={}): '''Register plugin. Called when used as an plugin.''' - if not isinstance(session, ftrack_api.session.Session): - return - CustomAttributeDoctor(session, plugins_presets).register() diff --git a/pype/ftrack/actions/action_delete_asset.py b/pype/ftrack/actions/action_delete_asset.py index 1b1e7fc905..106c81758a 100644 --- a/pype/ftrack/actions/action_delete_asset.py +++ b/pype/ftrack/actions/action_delete_asset.py @@ -85,7 +85,7 @@ class DeleteAsset(BaseAction): 'type': 'asset', 'name': entity['name'] }) - + if av_entity is None: return { 'success': False, @@ -314,12 +314,6 @@ class DeleteAsset(BaseAction): def register(session, plugins_presets={}): '''Register plugin. Called when used as an plugin.''' - # Validate that session is an instance of ftrack_api.Session. If not, - # assume that register is being called from an old or incompatible API and - # return without doing anything. - if not isinstance(session, ftrack_api.session.Session): - return - DeleteAsset(session, plugins_presets).register() diff --git a/pype/ftrack/actions/action_delete_asset_byname.py b/pype/ftrack/actions/action_delete_asset_byname.py index 2431b2311e..4a3807f8f0 100644 --- a/pype/ftrack/actions/action_delete_asset_byname.py +++ b/pype/ftrack/actions/action_delete_asset_byname.py @@ -135,12 +135,6 @@ class AssetsRemover(BaseAction): def register(session, plugins_presets={}): '''Register plugin. Called when used as an plugin.''' - # Validate that session is an instance of ftrack_api.Session. If not, - # assume that register is being called from an old or incompatible API and - # return without doing anything. - if not isinstance(session, ftrack_api.session.Session): - return - AssetsRemover(session, plugins_presets).register() diff --git a/pype/ftrack/actions/action_djvview.py b/pype/ftrack/actions/action_djvview.py index 58914fbc1e..9da12dd67c 100644 --- a/pype/ftrack/actions/action_djvview.py +++ b/pype/ftrack/actions/action_djvview.py @@ -220,8 +220,6 @@ class DJVViewAction(BaseAction): def register(session, plugins_presets={}): """Register hooks.""" - if not isinstance(session, ftrack_api.session.Session): - return DJVViewAction(session, plugins_presets).register() diff --git a/pype/ftrack/actions/action_job_killer.py b/pype/ftrack/actions/action_job_killer.py index 717f87e879..64fb99133d 100644 --- a/pype/ftrack/actions/action_job_killer.py +++ b/pype/ftrack/actions/action_job_killer.py @@ -121,12 +121,6 @@ class JobKiller(BaseAction): def register(session, plugins_presets={}): '''Register plugin. Called when used as an plugin.''' - # Validate that session is an instance of ftrack_api.Session. If not, - # assume that register is being called from an old or incompatible API and - # return without doing anything. - if not isinstance(session, ftrack_api.session.Session): - return - JobKiller(session, plugins_presets).register() diff --git a/pype/ftrack/actions/action_multiple_notes.py b/pype/ftrack/actions/action_multiple_notes.py index 6e28b7bed6..bd51cb2984 100644 --- a/pype/ftrack/actions/action_multiple_notes.py +++ b/pype/ftrack/actions/action_multiple_notes.py @@ -115,9 +115,6 @@ class MultipleNotes(BaseAction): def register(session, plugins_presets={}): '''Register plugin. Called when used as an plugin.''' - if not isinstance(session, ftrack_api.session.Session): - return - MultipleNotes(session, plugins_presets).register() diff --git a/pype/ftrack/actions/action_prepare_project.py b/pype/ftrack/actions/action_prepare_project.py index e914fa74f0..d645748f6f 100644 --- a/pype/ftrack/actions/action_prepare_project.py +++ b/pype/ftrack/actions/action_prepare_project.py @@ -372,7 +372,4 @@ class PrepareProject(BaseAction): def register(session, plugins_presets={}): '''Register plugin. Called when used as an plugin.''' - if not isinstance(session, ftrack_api.session.Session): - return - PrepareProject(session, plugins_presets).register() diff --git a/pype/ftrack/actions/action_rv.py b/pype/ftrack/actions/action_rv.py index 6b6591355f..69c6624b71 100644 --- a/pype/ftrack/actions/action_rv.py +++ b/pype/ftrack/actions/action_rv.py @@ -328,8 +328,6 @@ class RVAction(BaseAction): def register(session, plugins_presets={}): """Register hooks.""" - if not isinstance(session, ftrack_api.session.Session): - return RVAction(session, plugins_presets).register() diff --git a/pype/ftrack/actions/action_start_timer.py b/pype/ftrack/actions/action_start_timer.py index 36752a1edc..292789e9f3 100644 --- a/pype/ftrack/actions/action_start_timer.py +++ b/pype/ftrack/actions/action_start_timer.py @@ -26,7 +26,7 @@ class StartTimer(BaseAction): user.start_timer(entity, force=True) self.session.commit() - + self.log.info( "Starting Ftrack timer for task: {}".format(entity['name']) ) @@ -37,7 +37,4 @@ class StartTimer(BaseAction): def register(session, plugins_presets={}): '''Register plugin. Called when used as an plugin.''' - if not isinstance(session, ftrack_api.session.Session): - return - StartTimer(session, plugins_presets).register() diff --git a/pype/ftrack/actions/action_sync_hier_attrs_local.py b/pype/ftrack/actions/action_sync_hier_attrs_local.py index 05a70461a1..289abd0122 100644 --- a/pype/ftrack/actions/action_sync_hier_attrs_local.py +++ b/pype/ftrack/actions/action_sync_hier_attrs_local.py @@ -309,9 +309,6 @@ class SyncHierarchicalAttrs(BaseAction): def register(session, plugins_presets={}): '''Register plugin. Called when used as an plugin.''' - if not isinstance(session, ftrack_api.session.Session): - return - SyncHierarchicalAttrs(session, plugins_presets).register() diff --git a/pype/ftrack/actions/action_sync_to_avalon_local.py b/pype/ftrack/actions/action_sync_to_avalon_local.py index ddf8ed6571..61050f9883 100644 --- a/pype/ftrack/actions/action_sync_to_avalon_local.py +++ b/pype/ftrack/actions/action_sync_to_avalon_local.py @@ -263,11 +263,4 @@ class SyncToAvalon(BaseAction): def register(session, plugins_presets={}): '''Register plugin. Called when used as an plugin.''' - - # Validate that session is an instance of ftrack_api.Session. If not, - # assume that register is being called from an old or incompatible API and - # return without doing anything. - if not isinstance(session, ftrack_api.session.Session): - return - SyncToAvalon(session, plugins_presets).register() diff --git a/pype/ftrack/actions/action_test.py b/pype/ftrack/actions/action_test.py index a2bc8bf892..58f7210e3b 100644 --- a/pype/ftrack/actions/action_test.py +++ b/pype/ftrack/actions/action_test.py @@ -43,9 +43,6 @@ class TestAction(BaseAction): def register(session, plugins_presets={}): '''Register plugin. Called when used as an plugin.''' - if not isinstance(session, ftrack_api.session.Session): - return - TestAction(session, plugins_presets).register() diff --git a/pype/ftrack/actions/action_thumbnail_to_childern.py b/pype/ftrack/actions/action_thumbnail_to_childern.py index 101b678512..7d189cf652 100644 --- a/pype/ftrack/actions/action_thumbnail_to_childern.py +++ b/pype/ftrack/actions/action_thumbnail_to_childern.py @@ -68,8 +68,6 @@ class ThumbToChildren(BaseAction): def register(session, plugins_presets={}): '''Register action. Called when used as an event plugin.''' - if not isinstance(session, ftrack_api.session.Session): - return ThumbToChildren(session, plugins_presets).register() diff --git a/pype/ftrack/actions/action_thumbnail_to_parent.py b/pype/ftrack/actions/action_thumbnail_to_parent.py index c382d9303c..efafca4a96 100644 --- a/pype/ftrack/actions/action_thumbnail_to_parent.py +++ b/pype/ftrack/actions/action_thumbnail_to_parent.py @@ -90,8 +90,6 @@ class ThumbToParent(BaseAction): def register(session, plugins_presets={}): '''Register action. Called when used as an event plugin.''' - if not isinstance(session, ftrack_api.session.Session): - return ThumbToParent(session, plugins_presets).register() diff --git a/pype/ftrack/actions/action_where_run_ask.py b/pype/ftrack/actions/action_where_run_ask.py index 0351c09909..795c2664cc 100644 --- a/pype/ftrack/actions/action_where_run_ask.py +++ b/pype/ftrack/actions/action_where_run_ask.py @@ -40,7 +40,4 @@ class ActionAskWhereIRun(BaseAction): def register(session, plugins_presets={}): '''Register plugin. Called when used as an plugin.''' - if not isinstance(session, ftrack_api.session.Session): - return - ActionAskWhereIRun(session, plugins_presets).register() diff --git a/pype/ftrack/actions/action_where_run_show.py b/pype/ftrack/actions/action_where_run_show.py index 7fea23e3b7..48618f0251 100644 --- a/pype/ftrack/actions/action_where_run_show.py +++ b/pype/ftrack/actions/action_where_run_show.py @@ -80,7 +80,4 @@ class ActionShowWhereIRun(BaseAction): def register(session, plugins_presets={}): '''Register plugin. Called when used as an plugin.''' - if not isinstance(session, ftrack_api.session.Session): - return - ActionShowWhereIRun(session, plugins_presets).register() diff --git a/pype/ftrack/events/action_sync_hier_attrs.py b/pype/ftrack/events/action_sync_hier_attrs.py index c9d968ee5d..23ac319261 100644 --- a/pype/ftrack/events/action_sync_hier_attrs.py +++ b/pype/ftrack/events/action_sync_hier_attrs.py @@ -220,7 +220,7 @@ class SyncHierarchicalAttrs(BaseAction): if job['status'] in ('queued', 'running'): job['status'] = 'failed' session.commit() - + if self.interface_messages: self.show_interface_from_dict( messages=self.interface_messages, @@ -341,9 +341,6 @@ class SyncHierarchicalAttrs(BaseAction): def register(session, plugins_presets): '''Register plugin. Called when used as an plugin.''' - if not isinstance(session, ftrack_api.session.Session): - return - SyncHierarchicalAttrs(session, plugins_presets).register() diff --git a/pype/ftrack/events/action_sync_to_avalon.py b/pype/ftrack/events/action_sync_to_avalon.py index 51a4ae9475..7b5f94f216 100644 --- a/pype/ftrack/events/action_sync_to_avalon.py +++ b/pype/ftrack/events/action_sync_to_avalon.py @@ -296,9 +296,6 @@ def register(session, plugins_presets): # Validate that session is an instance of ftrack_api.Session. If not, # assume that register is being called from an old or incompatible API and # return without doing anything. - if not isinstance(session, ftrack_api.session.Session): - return - SyncToAvalon(session, plugins_presets).register() diff --git a/pype/ftrack/events/event_del_avalon_id_from_new.py b/pype/ftrack/events/event_del_avalon_id_from_new.py index 6f6320f51b..e5c4b1be45 100644 --- a/pype/ftrack/events/event_del_avalon_id_from_new.py +++ b/pype/ftrack/events/event_del_avalon_id_from_new.py @@ -53,7 +53,5 @@ class DelAvalonIdFromNew(BaseEvent): def register(session, plugins_presets): '''Register plugin. Called when used as an plugin.''' - if not isinstance(session, ftrack_api.session.Session): - return DelAvalonIdFromNew(session, plugins_presets).register() diff --git a/pype/ftrack/events/event_next_task_update.py b/pype/ftrack/events/event_next_task_update.py index 18a7abf328..51ccb2f057 100644 --- a/pype/ftrack/events/event_next_task_update.py +++ b/pype/ftrack/events/event_next_task_update.py @@ -88,7 +88,5 @@ class NextTaskUpdate(BaseEvent): def register(session, plugins_presets): '''Register plugin. Called when used as an plugin.''' - if not isinstance(session, ftrack_api.session.Session): - return NextTaskUpdate(session, plugins_presets).register() diff --git a/pype/ftrack/events/event_radio_buttons.py b/pype/ftrack/events/event_radio_buttons.py index 9c6f2d490a..917c7a49e6 100644 --- a/pype/ftrack/events/event_radio_buttons.py +++ b/pype/ftrack/events/event_radio_buttons.py @@ -36,7 +36,5 @@ class Radio_buttons(BaseEvent): def register(session, plugins_presets): '''Register plugin. Called when used as an plugin.''' - if not isinstance(session, ftrack_api.session.Session): - return Radio_buttons(session, plugins_presets).register() diff --git a/pype/ftrack/events/event_sync_hier_attr.py b/pype/ftrack/events/event_sync_hier_attr.py index 5ddc2394af..8031ec9e55 100644 --- a/pype/ftrack/events/event_sync_hier_attr.py +++ b/pype/ftrack/events/event_sync_hier_attr.py @@ -209,7 +209,5 @@ class SyncHierarchicalAttrs(BaseEvent): def register(session, plugins_presets): '''Register plugin. Called when used as an plugin.''' - if not isinstance(session, ftrack_api.session.Session): - return SyncHierarchicalAttrs(session, plugins_presets).register() diff --git a/pype/ftrack/events/event_sync_to_avalon.py b/pype/ftrack/events/event_sync_to_avalon.py index 4e7b208726..a25866be65 100644 --- a/pype/ftrack/events/event_sync_to_avalon.py +++ b/pype/ftrack/events/event_sync_to_avalon.py @@ -122,8 +122,4 @@ class Sync_to_Avalon(BaseEvent): def register(session, plugins_presets): '''Register plugin. Called when used as an plugin.''' - - if not isinstance(session, ftrack_api.session.Session): - return - Sync_to_Avalon(session, plugins_presets).register() diff --git a/pype/ftrack/events/event_test.py b/pype/ftrack/events/event_test.py index 94d99dbf67..a909aa5510 100644 --- a/pype/ftrack/events/event_test.py +++ b/pype/ftrack/events/event_test.py @@ -8,7 +8,7 @@ from pype.ftrack import BaseEvent class Test_Event(BaseEvent): ignore_me = True - + priority = 10000 def launch(self, session, event): @@ -22,7 +22,5 @@ class Test_Event(BaseEvent): def register(session, plugins_presets): '''Register plugin. Called when used as an plugin.''' - if not isinstance(session, ftrack_api.session.Session): - return Test_Event(session, plugins_presets).register() diff --git a/pype/ftrack/events/event_thumbnail_updates.py b/pype/ftrack/events/event_thumbnail_updates.py index 51bb15a4c7..ae6f8adb5e 100644 --- a/pype/ftrack/events/event_thumbnail_updates.py +++ b/pype/ftrack/events/event_thumbnail_updates.py @@ -47,7 +47,5 @@ class ThumbnailEvents(BaseEvent): def register(session, plugins_presets): '''Register plugin. Called when used as an plugin.''' - if not isinstance(session, ftrack_api.session.Session): - return ThumbnailEvents(session, plugins_presets).register() diff --git a/pype/ftrack/events/event_user_assigment.py b/pype/ftrack/events/event_user_assigment.py index fe8b331629..61699d736c 100644 --- a/pype/ftrack/events/event_user_assigment.py +++ b/pype/ftrack/events/event_user_assigment.py @@ -233,7 +233,5 @@ def register(session, plugins_presets): """ Register plugin. Called when used as an plugin. """ - if not isinstance(session, ftrack_api.session.Session): - return UserAssigmentEvent(session, plugins_presets).register() diff --git a/pype/ftrack/events/event_version_to_task_statuses.py b/pype/ftrack/events/event_version_to_task_statuses.py index 85a31383d5..66a55c0cf7 100644 --- a/pype/ftrack/events/event_version_to_task_statuses.py +++ b/pype/ftrack/events/event_version_to_task_statuses.py @@ -71,7 +71,5 @@ class VersionToTaskStatus(BaseEvent): def register(session, plugins_presets): '''Register plugin. Called when used as an plugin.''' - if not isinstance(session, ftrack_api.session.Session): - return VersionToTaskStatus(session, plugins_presets).register() diff --git a/pype/ftrack/lib/ftrack_base_handler.py b/pype/ftrack/lib/ftrack_base_handler.py index 9eda74f0f3..9821bfd81f 100644 --- a/pype/ftrack/lib/ftrack_base_handler.py +++ b/pype/ftrack/lib/ftrack_base_handler.py @@ -31,8 +31,21 @@ class BaseHandler(object): def __init__(self, session, plugins_presets={}): '''Expects a ftrack_api.Session instance''' - self._session = session self.log = Logger().get_logger(self.__class__.__name__) + if not isinstance(session, ftrack_api.session.Session): + self.log.warning(( + "Session object entered with args is instance of \"{}\"" + " but expected instance is \"{}\"." + ).format( + str(type(session)), + str(ftrack_api.session.Session.__qualname__) + )) + self.register = self.register_without_session + self._session = None + + return + + self._session = session # Using decorator self.register = self.register_decorator(self.register)