From 09da3d1beebaaeebb52f9bd2f8298b659ddc44d6 Mon Sep 17 00:00:00 2001 From: Ionite Date: Sun, 24 Sep 2023 23:26:26 -0400 Subject: [PATCH] Improve apc encoding with json --- StabilityMatrix.Avalonia/Assets/sitecustomize.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/StabilityMatrix.Avalonia/Assets/sitecustomize.py b/StabilityMatrix.Avalonia/Assets/sitecustomize.py index c51abc9d..8c2718f4 100644 --- a/StabilityMatrix.Avalonia/Assets/sitecustomize.py +++ b/StabilityMatrix.Avalonia/Assets/sitecustomize.py @@ -6,6 +6,7 @@ so we can prompt the user to enter something. """ import sys +import json # Application Program Command escape sequence # This wraps messages sent to the parent process. @@ -20,11 +21,13 @@ def send_apc(msg: str): sys.stdout.write(esc_apc + esc_prefix + msg + esc_st) sys.stdout.flush() +def send_apc_json(type: str, data: str): + """Send an APC Json message.""" + send_apc(json.dumps({"type": type, "data": data})) def send_apc_input(prompt: str): """Apc message for input() prompt.""" - send_apc('{"type":"input","data":"' + str(prompt) + '"}') - + send_apc_json("input", prompt) def audit(event: str, *args): """Main audit hook function."""