From 0646e607b537b43901db53c743ec2011a375f5e2 Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 26 Apr 2019 15:22:14 +1000 Subject: ports: Convert to use pyexec_file_if_exists() to execute boot/main.py. The stm32 and nrf ports already had the behaviour that they would first check if the script exists before executing it, and this patch makes all other ports work the same way. This helps when developing apps because it's hard to tell (when unconditionally trying to execute the scripts) if the resulting OSError at boot up comes from missing boot.py or main.py, or from some other error. And it's not really an error if these scripts don't exist. --- ports/teensy/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ports/teensy') diff --git a/ports/teensy/main.c b/ports/teensy/main.c index ad98a4364..1f529f589 100644 --- a/ports/teensy/main.c +++ b/ports/teensy/main.c @@ -302,7 +302,7 @@ soft_reset: #if MICROPY_MODULE_FROZEN pyexec_frozen_module("boot.py"); #else - if (!pyexec_file("/boot.py")) { + if (!pyexec_file_if_exists("/boot.py")) { flash_error(4); } #endif @@ -322,7 +322,7 @@ soft_reset: } else { vstr_add_str(vstr, mp_obj_str_get_str(pyb_config_main)); } - if (!pyexec_file(vstr_null_terminated_str(vstr))) { + if (!pyexec_file_if_exists(vstr_null_terminated_str(vstr))) { flash_error(3); } vstr_free(vstr); -- cgit v1.2.3