Plugin base classes: update method signatures & fix raise (#598)
This way IDEs can verify method overrides in subclasses, otherwise these are flagged as erroneous. Changed base classes to properly raise NotImplementedError; previously they would cause "TypeError: exceptions must derive from BaseException" Also fixed exception handling in sources.service.clean().
This commit is contained in:
@ -13,5 +13,5 @@ class DestinationPlugin(Plugin):
|
||||
type = 'destination'
|
||||
requires_key = True
|
||||
|
||||
def upload(self):
|
||||
raise NotImplemented
|
||||
def upload(self, name, body, private_key, cert_chain, options, **kwargs):
|
||||
raise NotImplementedError
|
||||
|
@ -17,5 +17,5 @@ class ExportPlugin(Plugin):
|
||||
type = 'export'
|
||||
requires_key = True
|
||||
|
||||
def export(self):
|
||||
raise NotImplemented
|
||||
def export(self, body, chain, key, options, **kwargs):
|
||||
raise NotImplementedError
|
||||
|
@ -16,8 +16,8 @@ class IssuerPlugin(Plugin):
|
||||
"""
|
||||
type = 'issuer'
|
||||
|
||||
def create_certificate(self):
|
||||
def create_certificate(self, csr, issuer_options):
|
||||
raise NotImplementedError
|
||||
|
||||
def create_authority(self):
|
||||
raise NotImplemented
|
||||
def create_authority(self, options):
|
||||
raise NotImplementedError
|
||||
|
@ -12,5 +12,5 @@ from lemur.plugins.base import Plugin
|
||||
class MetricPlugin(Plugin):
|
||||
type = 'metric'
|
||||
|
||||
def submit(self, *args, **kwargs):
|
||||
raise NotImplemented
|
||||
def submit(self, metric_name, metric_type, metric_value, metric_tags=None, options=None):
|
||||
raise NotImplementedError
|
||||
|
@ -22,14 +22,14 @@ class SourcePlugin(Plugin):
|
||||
}
|
||||
]
|
||||
|
||||
def get_certificates(self):
|
||||
raise NotImplemented
|
||||
def get_certificates(self, options, **kwargs):
|
||||
raise NotImplementedError
|
||||
|
||||
def get_endpoints(self):
|
||||
raise NotImplemented
|
||||
def get_endpoints(self, options, **kwargs):
|
||||
raise NotImplementedError
|
||||
|
||||
def clean(self):
|
||||
raise NotImplemented
|
||||
def clean(self, options, **kwargs):
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
def options(self):
|
||||
|
@ -198,7 +198,7 @@ def clean(source):
|
||||
|
||||
try:
|
||||
certificates = s.clean(source.options)
|
||||
except NotImplemented:
|
||||
except NotImplementedError:
|
||||
current_app.logger.warning("Cannot clean source: {0}, source plugin does not implement 'clean()'".format(
|
||||
source.label
|
||||
))
|
||||
|
Reference in New Issue
Block a user