mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-09 17:07:43 +01:00
Added interim plugin list function
This commit is contained in:
parent
a81a365113
commit
f8bd353f02
5 changed files with 43 additions and 5 deletions
|
@ -1 +1 @@
|
||||||
__version__ = "4.0.0.39"
|
__version__ = "4.0.0.40"
|
||||||
|
|
|
@ -16,6 +16,7 @@ import yaml
|
||||||
import click
|
import click
|
||||||
from subprocess import call
|
from subprocess import call
|
||||||
import zipfile
|
import zipfile
|
||||||
|
from importlib_metadata import version, metadata
|
||||||
|
|
||||||
from jinja2 import Template
|
from jinja2 import Template
|
||||||
|
|
||||||
|
@ -248,13 +249,17 @@ def plugin_remove(package_name):
|
||||||
|
|
||||||
def plugins_list():
|
def plugins_list():
|
||||||
print("--------------------------------------")
|
print("--------------------------------------")
|
||||||
print("List of active pluigins")
|
print("List of active plugins")
|
||||||
try:
|
try:
|
||||||
with open(os.path.join(".", 'config', "config.yaml"), 'rt') as f:
|
with open(os.path.join(".", 'config', "config.yaml"), 'rt') as f:
|
||||||
data = yaml.load(f, Loader=yaml.FullLoader)
|
data = yaml.load(f, Loader=yaml.FullLoader)
|
||||||
|
|
||||||
for p in data["plugins"]:
|
for p in data["plugins"]:
|
||||||
print("- {}".format(p))
|
p_metadata= metadata(p)
|
||||||
|
p_Homepage= p_metadata['Home-page']
|
||||||
|
p_version = p_metadata['Version']
|
||||||
|
p_Author = p_metadata['Author']
|
||||||
|
print("- ({})\t{}".format(p_version,p))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
|
from importlib_metadata import version, metadata
|
||||||
import datetime
|
import datetime
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
import asyncio
|
||||||
import yaml
|
import yaml
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
@ -167,3 +169,31 @@ class PluginController():
|
||||||
{"method": method_name, "label": key, "parameters": parameters})
|
{"method": method_name, "label": key, "parameters": parameters})
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
async def load_plugin_list(self):
|
||||||
|
result = []
|
||||||
|
try:
|
||||||
|
with open(os.path.join(".", 'config', "config.yaml"), 'rt') as f:
|
||||||
|
data = yaml.load(f, Loader=yaml.FullLoader)
|
||||||
|
|
||||||
|
for p in data["plugins"]:
|
||||||
|
try:
|
||||||
|
p_metadata= metadata(p)
|
||||||
|
p_name = p_metadata['name']
|
||||||
|
p_version = p_metadata['Version']
|
||||||
|
p_summary = p_metadata['Summary']
|
||||||
|
p_homepage= p_metadata['Home-page']
|
||||||
|
p_author = p_metadata['Author']
|
||||||
|
p_author_email = p_metadata['Author-email']
|
||||||
|
p_license = p_metadata['License']
|
||||||
|
p_description = p_metadata['Description']
|
||||||
|
plugin_data = {'Name': p_name,'Version': p_version,'Summary': p_summary,'Homepage':p_homepage,'Author':p_author,'Email': p_author_email,'License': p_license,'Description': p_description}
|
||||||
|
result.append(plugin_data)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
# print("- ({})\t{}".format(p_version,p))
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
return []
|
||||||
|
pass
|
||||||
|
return result
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
from cbpi.api import request_mapping
|
from cbpi.api import request_mapping
|
||||||
from cbpi.utils import json_dumps
|
from cbpi.utils import json_dumps
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
class PluginHttpEndpoints:
|
class PluginHttpEndpoints:
|
||||||
|
@ -83,4 +84,5 @@ class PluginHttpEndpoints:
|
||||||
"405":
|
"405":
|
||||||
description: invalid HTTP Method
|
description: invalid HTTP Method
|
||||||
"""
|
"""
|
||||||
return web.json_response(await self.cbpi.plugin.load_plugin_list(), dumps=json_dumps)
|
plugin_list = await self.cbpi.plugin.load_plugin_list()
|
||||||
|
return web.json_response(plugin_list, dumps=json_dumps)
|
||||||
|
|
3
setup.py
3
setup.py
|
@ -38,7 +38,8 @@ setup(name='cbpi',
|
||||||
'psutil==5.8.0',
|
'psutil==5.8.0',
|
||||||
'numpy==1.20.3',
|
'numpy==1.20.3',
|
||||||
'scipy',
|
'scipy',
|
||||||
'cbpi4ui'] + (
|
'cbpi4ui',
|
||||||
|
'importlib_metadata'] + (
|
||||||
['RPi.GPIO'] if platform.uname()[1] == "raspberrypi" else [] ),
|
['RPi.GPIO'] if platform.uname()[1] == "raspberrypi" else [] ),
|
||||||
|
|
||||||
dependency_links=[
|
dependency_links=[
|
||||||
|
|
Loading…
Reference in a new issue