From 825ec90c6f0e3ffa8fd99db5a7f8148e560a0d62 Mon Sep 17 00:00:00 2001 From: Co de Waal Date: Wed, 5 Jul 2017 12:59:58 +0200 Subject: [PATCH] Update endpoints.py Add user-yaml to be able to load and test not-yet released plugins. Steps: Make your own plugins.yaml in github, with references to your plugin(s). Add parameter user_yaml like: user_yaml https://raw.githubusercontent.com/...user.../craftbeerpi-plugins/master/plugins.yaml User yaml http address After that you see your own plugins in addon-list. --- modules/addon/endpoints.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/modules/addon/endpoints.py b/modules/addon/endpoints.py index 5ecade3..1b30b25 100644 --- a/modules/addon/endpoints.py +++ b/modules/addon/endpoints.py @@ -14,6 +14,7 @@ import shutil blueprint = Blueprint('addon', __name__) +user_yaml = None modules = {} @@ -137,6 +138,15 @@ def plugins(): for key, value in cbpi.cache["plugins"].iteritems(): value["installed"] = os.path.isdir("./modules/plugins/%s/" % (key)) + user_yaml=cbpi.get_config_parameter("user_yaml", None) + if user_yaml is None: + pass + else: + response = requests.get(user_yaml) + cbpi.cache["plugins"] = merge(yaml.load(response.text), cbpi.cache["plugins"]) + for key, value in cbpi.cache["plugins"].iteritems(): + value["installed"] = os.path.isdir("./modules/plugins/%s/" % (key)) + return json.dumps(cbpi.cache["plugins"]) @@ -195,4 +205,12 @@ def initPlugins(app): @cbpi.initalizer(order=2) def init(cbpi): + global user_yaml + user_yaml = cbpi.get_config_parameter("user_yaml", None) + if user_yaml is None: + try: + cbpi.add_config_parameter("user_yaml", "", "text", "User yaml http address") + except: + pass + cbpi.app.register_blueprint(blueprint, url_prefix='/api/editor')