mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-09 17:07:43 +01:00
test
This commit is contained in:
parent
35252a2b83
commit
7fa738d240
4 changed files with 30 additions and 8 deletions
|
@ -1,3 +1,3 @@
|
|||
__version__ = "4.1.7"
|
||||
__version__ = "4.1.8.a1"
|
||||
__codename__ = "Groundhog Day"
|
||||
|
||||
|
|
|
@ -199,11 +199,12 @@ class Config:
|
|||
description: str = None
|
||||
type: ConfigType = ConfigType.STRING
|
||||
options: Any = None
|
||||
source: str = None
|
||||
|
||||
def __str__(self):
|
||||
return "....name={} value={}".format(self.name, self.value)
|
||||
def to_dict(self):
|
||||
return dict(name=self.name, value=self.value, type=self.type.value, description=self.description, options=self.options)
|
||||
return dict(name=self.name, value=self.value, type=self.type.value, description=self.description, options=self.options, source=self.source)
|
||||
|
||||
@dataclass
|
||||
class NotificationAction:
|
||||
|
|
|
@ -20,20 +20,17 @@ class ConfigController:
|
|||
self.logger.info("Config folder path : " + os.path.join(Path(self.cbpi.config_folder.configFolderPath).absolute()))
|
||||
|
||||
def get_state(self):
|
||||
|
||||
result = {}
|
||||
for key, value in self.cache.items():
|
||||
result[key] = value.to_dict()
|
||||
|
||||
return result
|
||||
|
||||
|
||||
async def init(self):
|
||||
self.static = load_config(self.path_static)
|
||||
with open(self.path) as json_file:
|
||||
data = json.load(json_file)
|
||||
for key, value in data.items():
|
||||
self.cache[key] = Config(name=value.get("name"), value=value.get("value"), description=value.get("description"), type=ConfigType(value.get("type", "string")), options=value.get("options", None) )
|
||||
self.cache[key] = Config(name=value.get("name"), value=value.get("value"), description=value.get("description"), type=ConfigType(value.get("type", "string")), options=value.get("options", None), source=value.get("source", "craftbeerpi") )
|
||||
|
||||
def get(self, name, default=None):
|
||||
self.logger.debug("GET CONFIG VALUE %s (default %s)" % (name, default))
|
||||
|
|
|
@ -205,6 +205,7 @@ class PluginController():
|
|||
from importlib.metadata import (distribution, metadata,
|
||||
version)
|
||||
meta = metadata(key)
|
||||
logging.warning(key)
|
||||
result.append({row: meta[row]
|
||||
for row in list(metadata(key))})
|
||||
except Exception as e:
|
||||
|
@ -215,3 +216,26 @@ class PluginController():
|
|||
logger.error(e)
|
||||
return []
|
||||
return result
|
||||
|
||||
async def load_plugin_names(self, filter="cbpi"):
|
||||
result = []
|
||||
result.append(dict(Name="craftbeerpi"))
|
||||
try:
|
||||
discovered_plugins = {
|
||||
name: importlib.import_module(name)
|
||||
for finder, name, ispkg
|
||||
in pkgutil.iter_modules()
|
||||
if name.startswith('cbpi') and len(name) > 4
|
||||
}
|
||||
for key, module in discovered_plugins.items():
|
||||
try:
|
||||
meta = metadata(key)
|
||||
result.append(dict(Name=meta["Name"]))
|
||||
|
||||
except Exception as e:
|
||||
logger.error("FAILED to load plugin {} ".format(key))
|
||||
logger.error(e)
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
return result
|
||||
return result
|
||||
|
|
Loading…
Reference in a new issue