Repository navigation
Expand file tree
/
Copy pathcli.py
More file actions
44 lines (34 loc) · 1.38 KB
/
Copy pathcli.py
File metadata and controls
44 lines (34 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import traceback
import logging
import pkg_resources
from sqlalchemy.exc import SQLAlchemyError
from dispatch.plugins.base import plugins, register
logger = logging.getLogger(__name__)
# Plugin endpoints should determine authentication # TODO allow them to specify (kglisson)
def install_plugin_events(api):
"""Adds plugin endpoints to the event router."""
for plugin in plugins.all():
if plugin.events:
api.include_router(plugin.events, prefix="/events", tags=["events"])
def install_plugins():
"""
Installs plugins associated with dispatch
:return:
"""
for ep in pkg_resources.iter_entry_points("dispatch.plugins"):
logger.info(f"Attempting to load plugin: {ep.name}")
try:
plugin = ep.load()
register(plugin)
logger.info(f"Successfully loaded plugin: {ep.name}")
except SQLAlchemyError:
logger.error(
"Something went wrong with creating plugin rows, is the database setup correctly?"
)
except KeyError as e:
logger.info(f"Failed to load plugin {ep.name} due to missing configuration items. {e}")
except Exception:
logger.error(f"Failed to load plugin {ep.name}:{traceback.format_exc()}")
def get_plugin_properties(json_schema):
for _, v in json_schema["definitions"].items():
return v["properties"]