mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merged in feature/action_preregister_implementation (pull request #354)
Feature/action preregister implementation Approved-by: Milan Kolar <milan@orbi.tools>
This commit is contained in:
commit
061e0056e5
3 changed files with 28 additions and 18 deletions
|
|
@ -36,12 +36,13 @@ class DJVViewAction(BaseAction):
|
||||||
'file_ext', ["img", "mov", "exr"]
|
'file_ext', ["img", "mov", "exr"]
|
||||||
)
|
)
|
||||||
|
|
||||||
def register(self):
|
def preregister(self):
|
||||||
assert (self.djv_path is not None), (
|
if self.djv_path is None:
|
||||||
'DJV View is not installed'
|
return (
|
||||||
' or paths in presets are not set correctly'
|
'DJV View is not installed'
|
||||||
)
|
' or paths in presets are not set correctly'
|
||||||
super().register()
|
)
|
||||||
|
return True
|
||||||
|
|
||||||
def discover(self, session, entities, event):
|
def discover(self, session, entities, event):
|
||||||
"""Return available actions based on *event*. """
|
"""Return available actions based on *event*. """
|
||||||
|
|
|
||||||
|
|
@ -61,12 +61,12 @@ class RVAction(BaseAction):
|
||||||
def set_rv_path(self):
|
def set_rv_path(self):
|
||||||
self.rv_path = self.config_data.get("rv_path")
|
self.rv_path = self.config_data.get("rv_path")
|
||||||
|
|
||||||
def register(self):
|
def preregister(self):
|
||||||
assert (self.rv_path is not None), (
|
if self.rv_path is None:
|
||||||
'RV is not installed'
|
return (
|
||||||
' or paths in presets are not set correctly'
|
'RV is not installed or paths in presets are not set correctly'
|
||||||
)
|
)
|
||||||
super().register()
|
return True
|
||||||
|
|
||||||
def get_components_from_entity(self, session, entity, components):
|
def get_components_from_entity(self, session, entity, components):
|
||||||
"""Get components from various entity types.
|
"""Get components from various entity types.
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,13 @@ class MissingPermision(Exception):
|
||||||
super().__init__(message)
|
super().__init__(message)
|
||||||
|
|
||||||
|
|
||||||
|
class PreregisterException(Exception):
|
||||||
|
def __init__(self, message=None):
|
||||||
|
if not message:
|
||||||
|
message = "Pre-registration conditions were not met"
|
||||||
|
super().__init__(message)
|
||||||
|
|
||||||
|
|
||||||
class BaseHandler(object):
|
class BaseHandler(object):
|
||||||
'''Custom Action base class
|
'''Custom Action base class
|
||||||
|
|
||||||
|
|
@ -89,15 +96,17 @@ class BaseHandler(object):
|
||||||
'!{} "{}" - You\'re missing required {} permissions'
|
'!{} "{}" - You\'re missing required {} permissions'
|
||||||
).format(self.type, label, str(MPE)))
|
).format(self.type, label, str(MPE)))
|
||||||
except AssertionError as ae:
|
except AssertionError as ae:
|
||||||
self.log.info((
|
self.log.warning((
|
||||||
'!{} "{}" - {}'
|
'!{} "{}" - {}'
|
||||||
).format(self.type, label, str(ae)))
|
).format(self.type, label, str(ae)))
|
||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
self.log.error((
|
self.log.error((
|
||||||
'{} "{}" - Register method is not implemented'
|
'{} "{}" - Register method is not implemented'
|
||||||
).format(
|
).format(self.type, label))
|
||||||
self.type, label)
|
except PreregisterException as exc:
|
||||||
)
|
self.log.warning((
|
||||||
|
'{} "{}" - {}'
|
||||||
|
).format(self.type, label, str(exc)))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log.error('{} "{}" - Registration failed ({})'.format(
|
self.log.error('{} "{}" - Registration failed ({})'.format(
|
||||||
self.type, label, str(e))
|
self.type, label, str(e))
|
||||||
|
|
@ -163,10 +172,10 @@ class BaseHandler(object):
|
||||||
|
|
||||||
if result is True:
|
if result is True:
|
||||||
return
|
return
|
||||||
msg = "Pre-register conditions were not met"
|
msg = None
|
||||||
if isinstance(result, str):
|
if isinstance(result, str):
|
||||||
msg = result
|
msg = result
|
||||||
raise Exception(msg)
|
raise PreregisterException(msg)
|
||||||
|
|
||||||
def preregister(self):
|
def preregister(self):
|
||||||
'''
|
'''
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue