Skip to content

Commit 2b25f92

Browse files
fix(dev): faulty main and boot.py were sometimes reported as missing
1 parent 7025644 commit 2b25f92

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/Watcher/scripts.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,28 @@ const scripts = {
1919
` if sys.modules[name].__file__ in ${JSON.stringify(modulesToDelete)}:`,
2020
' print("[dev] Clear module: " + sys.modules[name].__file__)',
2121
" del sys.modules[name]",
22+
2223
"try:",
2324
" print('[dev] Import boot.py')",
2425
" import boot",
25-
"except ImportError:",
26-
" print('[dev] No boot.py found. Skipped.')",
27-
"except Exception:",
28-
" print('[dev] Exception in boot.py')",
29-
" raise",
26+
"except KeyboardInterrupt: pass",
27+
"except Exception as e:",
28+
" if(str(e) == \"no module named 'boot'\"):",
29+
" print('[dev] No boot.py found. Skipped.')",
30+
" else:",
31+
" print('[dev] Could not import boot.py.')",
32+
" raise e",
33+
3034
"try:",
3135
" print('[dev] Import main.py')",
3236
" import main",
3337
"except KeyboardInterrupt: pass",
34-
"except ImportError:",
35-
" print('[dev] No main.py found. Skipped.')",
36-
"except Exception as e: raise e;",
38+
"except Exception as e:",
39+
" if(str(e) == \"no module named 'main'\"):",
40+
" print('[dev] No main.py found. Skipped.')",
41+
" else:",
42+
" print('[dev] Could not import main.py.')",
43+
" raise e",
3744
"",
3845
]
3946
.filter(Boolean)

test/suite/integration/devmode.basic.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ test("can use devmode", async () => {
5858
writeFileSync(projectPath1 + "/main.py", 'print("hello world again again")');
5959
await new Promise((resolve) => device.readUntil("hello world again again", resolve));
6060
});
61+
test('bad code in main.py is printed correctly"', async () => {
62+
writeFileSync(projectPath1 + "/main.py", "bad code");
63+
await new Promise((resolve) => device.readUntil("SyntaxError: invalid syntax", resolve));
64+
});
6165
test("can stop devMode", async () => {
6266
await pymakr.commands.stopDevMode({ project });
6367
assert(!project.watcher.active);

0 commit comments

Comments
 (0)