diff --git a/main.py b/main.py index f1f0c588..6a069ebc 100644 --- a/main.py +++ b/main.py @@ -222,9 +222,10 @@ restart_btn.add_event_cb(lambda event: machine.reset(),lv.EVENT.CLICKED,None) import _thread +import traceback def execute_script(script_source, is_file, lvgl_obj, return_to_launcher): - thread_id = _thread.get_ident(); + thread_id = _thread.get_ident() print(f"Thread {thread_id}: executing script") try: script_globals = { @@ -239,16 +240,21 @@ def execute_script(script_source, is_file, lvgl_obj, return_to_launcher): script_source = f.read() print(f"Thread {thread_id}: starting script") try: - exec(script_source, script_globals) + # Compile the script to catch syntax errors with better context + compiled_script = compile(script_source, '