fix: Cleanup plugin.py
All checks were successful
Build Docker / Build Image (push) Successful in 1m13s
All checks were successful
Build Docker / Build Image (push) Successful in 1m13s
This commit is contained in:
parent
40f520ba5e
commit
3290240a25
16
plugin.py
16
plugin.py
@ -5,7 +5,6 @@ import sys
|
|||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def listPlugins():
|
def listPlugins():
|
||||||
plugins = []
|
plugins = []
|
||||||
for file in os.listdir("plugins"):
|
for file in os.listdir("plugins"):
|
||||||
@ -45,6 +44,7 @@ def pluginExists(plugin: str):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def verifyPlugin(plugin: str):
|
def verifyPlugin(plugin: str):
|
||||||
signatures = []
|
signatures = []
|
||||||
try:
|
try:
|
||||||
@ -75,12 +75,6 @@ def hashPlugin(plugin: str):
|
|||||||
return sha256.hexdigest()
|
return sha256.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def getPluginData(pluginStr: str):
|
def getPluginData(pluginStr: str):
|
||||||
plugin = importlib.import_module("plugins."+pluginStr)
|
plugin = importlib.import_module("plugins."+pluginStr)
|
||||||
|
|
||||||
@ -104,10 +98,12 @@ def getPluginData(pluginStr: str):
|
|||||||
|
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
|
||||||
def getPluginFunctions(plugin: str):
|
def getPluginFunctions(plugin: str):
|
||||||
plugin = importlib.import_module("plugins."+plugin)
|
plugin = importlib.import_module("plugins."+plugin)
|
||||||
return plugin.functions
|
return plugin.functions
|
||||||
|
|
||||||
|
|
||||||
def runPluginFunction(plugin: str, function: str, params: dict, authentication: str):
|
def runPluginFunction(plugin: str, function: str, params: dict, authentication: str):
|
||||||
plugin_module = importlib.import_module("plugins."+plugin)
|
plugin_module = importlib.import_module("plugins."+plugin)
|
||||||
if function not in plugin_module.functions:
|
if function not in plugin_module.functions:
|
||||||
@ -134,7 +130,6 @@ def runPluginFunction(plugin: str, function: str, params: dict, authentication:
|
|||||||
if pluginHash not in signatures:
|
if pluginHash not in signatures:
|
||||||
return {"error": "Plugin not verified"}
|
return {"error": "Plugin not verified"}
|
||||||
|
|
||||||
|
|
||||||
# Call the function with provided parameters
|
# Call the function with provided parameters
|
||||||
try:
|
try:
|
||||||
result = plugin_function(params, authentication)
|
result = plugin_function(params, authentication)
|
||||||
@ -144,14 +139,17 @@ def runPluginFunction(plugin: str, function: str, params: dict, authentication:
|
|||||||
return {"error": str(e)}
|
return {"error": str(e)}
|
||||||
# return plugin.runFunction(function, params, authentication)
|
# return plugin.runFunction(function, params, authentication)
|
||||||
|
|
||||||
|
|
||||||
def getPluginFunctionInputs(plugin: str, function: str):
|
def getPluginFunctionInputs(plugin: str, function: str):
|
||||||
plugin = importlib.import_module("plugins."+plugin)
|
plugin = importlib.import_module("plugins."+plugin)
|
||||||
return plugin.functions[function]["params"]
|
return plugin.functions[function]["params"]
|
||||||
|
|
||||||
|
|
||||||
def getPluginFunctionReturns(plugin: str, function: str):
|
def getPluginFunctionReturns(plugin: str, function: str):
|
||||||
plugin = importlib.import_module("plugins."+plugin)
|
plugin = importlib.import_module("plugins."+plugin)
|
||||||
return plugin.functions[function]["returns"]
|
return plugin.functions[function]["returns"]
|
||||||
|
|
||||||
|
|
||||||
def getDomainFunctions():
|
def getDomainFunctions():
|
||||||
plugins = listPlugins()
|
plugins = listPlugins()
|
||||||
domainFunctions = []
|
domainFunctions = []
|
||||||
@ -166,6 +164,7 @@ def getDomainFunctions():
|
|||||||
})
|
})
|
||||||
return domainFunctions
|
return domainFunctions
|
||||||
|
|
||||||
|
|
||||||
def getSearchFunctions():
|
def getSearchFunctions():
|
||||||
plugins = listPlugins()
|
plugins = listPlugins()
|
||||||
searchFunctions = []
|
searchFunctions = []
|
||||||
@ -180,6 +179,7 @@ def getSearchFunctions():
|
|||||||
})
|
})
|
||||||
return searchFunctions
|
return searchFunctions
|
||||||
|
|
||||||
|
|
||||||
def getDashboardFunctions():
|
def getDashboardFunctions():
|
||||||
plugins = listPlugins()
|
plugins = listPlugins()
|
||||||
dashboardFunctions = []
|
dashboardFunctions = []
|
||||||
|
Loading…
Reference in New Issue
Block a user