From 38b7a3b481aa1d4007c1cab9597d89edbfe47e3d Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Tue, 3 Jun 2025 00:15:01 +0200 Subject: [PATCH] mpos.apps: add globals introspect --- internal_filesystem/lib/mpos/apps.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal_filesystem/lib/mpos/apps.py b/internal_filesystem/lib/mpos/apps.py index 9489bd1f..1d814c40 100644 --- a/internal_filesystem/lib/mpos/apps.py +++ b/internal_filesystem/lib/mpos/apps.py @@ -40,6 +40,13 @@ def execute_script(script_source, is_file, cwd=None): try: compiled_script = compile(script_source, compile_name, 'exec') exec(compiled_script, script_globals) + # Introspect globals + classes = {k: v for k, v in script_globals.items() if isinstance(v, type)} + functions = {k: v for k, v in script_globals.items() if callable(v) and not isinstance(v, type)} + variables = {k: v for k, v in script_globals.items() if not callable(v)} + print("Classes:", classes.keys()) + print("Functions:", functions.keys()) + print("Variables:", variables.keys()) except Exception as e: print(f"Thread {thread_id}: exception during execution:") # Print stack trace with exception type, value, and traceback