From 392c47dcef7829db38611772f47dd8ea268138d0 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Sun, 21 Apr 2024 03:47:01 +0200 Subject: [PATCH] MultiServer: add datastore list command to MultiServer (#3181) --- MultiServer.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/MultiServer.py b/MultiServer.py index 3052046a34..4936eb8c04 100644 --- a/MultiServer.py +++ b/MultiServer.py @@ -2163,6 +2163,18 @@ class ServerCommandProcessor(CommonCommandProcessor): self.ctx.broadcast_all([{"cmd": "RoomUpdate", option_name: getattr(self.ctx, option_name)}]) return True + def _cmd_datastore(self): + """Debug Tool: list writable datastorage keys and approximate the size of their values with pickle.""" + total: int = 0 + texts = [] + for key, value in self.ctx.stored_data.items(): + size = len(pickle.dumps(value)) + total += size + texts.append(f"Key: {key} | Size: {size}B") + texts.insert(0, f"Found {len(self.ctx.stored_data)} keys, " + f"approximately totaling {Utils.format_SI_prefix(total, power=1024)}B") + self.output("\n".join(texts)) + async def console(ctx: Context): import sys