Added check for plugin addition

before plugin is added to the config, cli.py checks if the package does exist and if the name is correct (capital letters,...)
This commit is contained in:
avollkopf 2022-02-15 18:11:14 +01:00
parent 259f5abc78
commit 972c9dbf49
2 changed files with 25 additions and 14 deletions

View file

@ -1 +1 @@
__version__ = "4.0.1.15" __version__ = "4.0.1.16"

View file

@ -218,7 +218,18 @@ def plugins_add(package_name):
return return
return return
installation = True
try: try:
try:
p_metadata= metadata(package_name)
p_name=p_metadata['Name']
if p_name != package_name:
print("Error. Package name {} does not exist. Did you mean {}".format(package_name,p_name))
installation = False
except Exception as e:
print("Error. Package {} cannot be found in installed packages".format(package_name))
installation = False
if installation:
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)
if package_name in data["plugins"]: if package_name in data["plugins"]: