mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 13:24:54 +01:00
_handle resunt cares only about result
This commit is contained in:
parent
fd2b278141
commit
411f795b6f
2 changed files with 16 additions and 29 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue