Skip to content

Commit d5bdaaa

Browse files
author
Jakob Rosenberg
authored
Merge pull request #269 from pycom/small-patch
Small-patch
2 parents 7025644 + 7ddc985 commit d5bdaaa

File tree

5 files changed

+48
-20
lines changed

5 files changed

+48
-20
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)

src/utils/Notifier.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ class Notifier {
9090
if (shouldStoreChoice === this.DONT_ASK_AGAIN) choice = this.DONT_ASK_AGAIN;
9191
if (shouldStoreChoice) {
9292
const config = this.pymakr.config.get().get("misc.notifications");
93-
this.pymakr.config.get().update(`misc.notifications`, { ...config, [id]: choice });
93+
this.pymakr.config
94+
.get()
95+
.update(`misc.notifications`, { ...config, [id]: choice }, vscode.ConfigurationTarget.Global);
9496
}
9597
}
9698

test/suite/integration/devmode.adv.test.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,29 @@ test("can fake deepsleep in devmode", async () => {
6262
});
6363

6464
test("machine.sleep gets transformed to fake_machine.sleep", async () => {
65-
writeFileSync(
66-
projectPath1 + "/main.py",
67-
["import machine", "# machine.sleep(100)", "# machine.deepSleep(100)", 'print("booted")'].join("\n")
68-
);
69-
await readUntil("booted");
70-
const result = await device.adapter.getFile("main.py");
71-
assert.equal(
72-
result.toString(),
73-
["import fake_machine", "# fake_machine.sleep(100)", "# fake_machine.sleep(100)", 'print("booted")'].join("\n")
74-
);
65+
test("can write main.py", async () => {
66+
writeFileSync(
67+
projectPath1 + "/main.py",
68+
["import machine", "# machine.sleep(100)", "# machine.deepSleep(100)", 'print("booted")'].join("\n")
69+
);
70+
await readUntil("booted");
71+
});
72+
test("can read main.py", async () => {
73+
const result = await device.adapter.getFile("main.py");
74+
assert.equal(
75+
result.toString(),
76+
["import fake_machine", "# fake_machine.sleep(100)", "# fake_machine.sleep(100)", 'print("booted")'].join(
77+
"\n"
78+
)
79+
);
80+
});
81+
});
82+
83+
test("can stop devMode", async () => {
84+
await pymakr.commands.stopDevMode({ project });
85+
assert(!project.watcher.active);
86+
assert.equal(project.watcher.deviceManagers.length, 0);
87+
await new Promise((resolve) => setTimeout(resolve, 100));
7588
});
7689

7790
// todo can't interrupt loop. needs fix

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);

test/suite/integration/probs.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const PROJECT_STORE_TIMEOUT = 10000;
99
*/
1010
const prepDevice = async (device) => {
1111
device.adapter.__proxyMeta.clearQueue();
12+
device.adapter.__proxyMeta.skipCurrent();
1213
console.log("[PREP] Waiting for idle...");
1314
await device.adapter.__proxyMeta.idle;
1415
await device.connect();
@@ -26,7 +27,8 @@ const prepDevice = async (device) => {
2627
};
2728

2829
module.exports = {
29-
async setupFile() {
30+
async setupFile(file) {
31+
console.log("[PREP]", file);
3032
resetFixture(workspaceDir);
3133
/** @type {PyMakr} */
3234
let pymakr;

0 commit comments

Comments
 (0)