From 8e7c6eedba7db97836ecbbe1076640439565a9ab Mon Sep 17 00:00:00 2001 From: Felipe M Date: Tue, 2 Feb 2021 12:55:17 +0100 Subject: [PATCH] Database and logging fixes --- butterrobot/admin/blueprint.py | 4 +--- butterrobot/app.py | 1 + butterrobot/db.py | 4 ++-- butterrobot/objects.py | 2 +- butterrobot/plugins.py | 1 - butterrobot/queue.py | 2 -- 6 files changed, 5 insertions(+), 9 deletions(-) diff --git a/butterrobot/admin/blueprint.py b/butterrobot/admin/blueprint.py index c59b1b3..1471822 100644 --- a/butterrobot/admin/blueprint.py +++ b/butterrobot/admin/blueprint.py @@ -52,7 +52,6 @@ def load_logged_in_user(): @login_required def index_view(): if not session.get("logged_in", False): - logger.info(url_for("admin.login_view")) return redirect(url_for("admin.login_view")) return redirect(url_for("admin.channel_list_view")) @@ -92,7 +91,6 @@ def plugin_list_view(): @admin.route("/channels") @login_required def channel_list_view(): - channels = ChannelQuery.all() return render_template("channel_list.j2", channels=ChannelQuery.all()) @@ -148,6 +146,6 @@ def channel_plugin_detail_view(channel_plugin_id): @admin.route("/channelplugins//delete", methods=["POST"]) @login_required def channel_plugin_delete_view(channel_plugin_id): - ChannelPluginQuery.delete(channel_plugin_id=channel_plugin_id) + ChannelPluginQuery.delete(channel_plugin_id) flash("Plugin removed", category="success") return redirect(request.headers.get("Referer")) diff --git a/butterrobot/app.py b/butterrobot/app.py index 582f22a..8301a5d 100644 --- a/butterrobot/app.py +++ b/butterrobot/app.py @@ -41,6 +41,7 @@ def incoming_platform_message_view(platform, path=None): return {} + @app.route("/healthz") def healthz(): return {} diff --git a/butterrobot/db.py b/butterrobot/db.py index 13051e7..5a6a130 100644 --- a/butterrobot/db.py +++ b/butterrobot/db.py @@ -1,5 +1,4 @@ import hashlib -import os from typing import Union import dataset @@ -158,4 +157,5 @@ class ChannelPluginQuery(Query): @classmethod def delete_by_channel(cls, channel_id): - cls.delete(channel_id=channel_id) + channel_plugins = cls.get_from_channel_id(channel_id) + [cls.delete(item.id) for item in channel_plugins] diff --git a/butterrobot/objects.py b/butterrobot/objects.py index ba15cd0..215924b 100644 --- a/butterrobot/objects.py +++ b/butterrobot/objects.py @@ -28,7 +28,7 @@ class Channel: def has_enabled_plugin(self, plugin_id): if plugin_id not in self.plugins: - logger.info("No enabled!", plugin_id=plugin_id, plugins=self.plugins) + logger.debug("No enabled!", plugin_id=plugin_id, plugins=self.plugins) return False return self.plugins[plugin_id].enabled diff --git a/butterrobot/plugins.py b/butterrobot/plugins.py index 97ee686..0ee3b55 100644 --- a/butterrobot/plugins.py +++ b/butterrobot/plugins.py @@ -64,5 +64,4 @@ def get_available_plugins(): module=ep.module_name, ) - logger.info("Plugins loaded", plugins=list(plugins.keys())) return plugins diff --git a/butterrobot/queue.py b/butterrobot/queue.py index fb1f490..82f99a7 100644 --- a/butterrobot/queue.py +++ b/butterrobot/queue.py @@ -29,8 +29,6 @@ def handle_message(platform: str, request: dict): ) return - logger.info("Received request", platform=platform, message=message) - if not message or message.from_bot: return