diff --git a/pype/ftrack/lib/ftrack_action_handler.py b/pype/ftrack/lib/ftrack_action_handler.py index 81c6421f52..3c0e55757b 100644 --- a/pype/ftrack/lib/ftrack_action_handler.py +++ b/pype/ftrack/lib/ftrack_action_handler.py @@ -156,41 +156,33 @@ class BaseAction(BaseHandler): return self._handle_result(response) - def _handle_result(self, session, result, entities, event): + def _handle_result(self, result): '''Validate the returned result from the action callback''' if isinstance(result, bool): if result is True: - result = { - 'success': result, - 'message': ( - '{0} launched successfully.'.format(self.label) - ) - } + msg = 'Action {0} finished.' else: - result = { - 'success': result, - 'message': ( - '{0} launch failed.'.format(self.label) - ) - } + msg = 'Action {0} failed.' - elif isinstance(result, dict): + return { + 'success': result, + 'message': msg.format(self.label) + } + + if isinstance(result, dict): if 'items' in result: if not isinstance(result['items'], list): raise ValueError('Invalid items format, must be list!') else: for key in ('success', 'message'): - if key in result: + if key not in result: continue + raise KeyError('Missing required key: {0}.'.format(key)) + return result - raise KeyError( - 'Missing required key: {0}.'.format(key) - ) - - else: - self.log.error( - 'Invalid result type must be bool or dictionary!' - ) + self.log.warning(( + 'Invalid result type \"{}\" must be bool or dictionary!' + ).format(str(type(result)))) return result diff --git a/pype/ftrack/lib/ftrack_base_handler.py b/pype/ftrack/lib/ftrack_base_handler.py index 6a78a19929..f0fd3b7354 100644 --- a/pype/ftrack/lib/ftrack_base_handler.py +++ b/pype/ftrack/lib/ftrack_base_handler.py @@ -335,7 +335,7 @@ class BaseHandler(object): return False - def _handle_result(self, session, result, entities, event): + def _handle_result(self, result): '''Validate the returned result from the action callback''' if isinstance(result, bool): if result is True: @@ -364,11 +364,6 @@ class BaseHandler(object): 'Missing required key: {0}.'.format(key) ) - else: - self.log.error( - 'Invalid result type must be bool or dictionary!' - ) - return result def show_message(self, event, input_message, result=False):