Skip to content

Commit 5c5c33c

Browse files
authored
Merge pull request #3 from makermelissa/main
Fix Read Textfile bug and output python errors to console
2 parents 7df3a12 + 09808e3 commit 5c5c33c

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"publishConfig": {
44
"registry": "https://npm.pkg.github.com"
55
},
6-
"version": "1.2.3",
6+
"version": "2.0.1",
77
"description": "A JavaScript Module to help with interfacing to the REPL on CircuitPython Devices over serial",
88
"main": "repl.js",
99
"exports": {

repl.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,13 @@ export class FileOps {
6464

6565
async _checkReplErrors() {
6666
let error = this._repl.getErrorOutput();
67-
if (error && error.type == "OSError" && error.errno == 30) {
68-
this._isReadOnly = true;
69-
// Throw an error if needed
70-
await this._checkReadOnly();
67+
if (error) {
68+
console.error("Python Error - " + error.type + ": " + error.message);
69+
if (error.type == "OSError" && error.errno == 30) {
70+
this._isReadOnly = true;
71+
// Throw an error if needed
72+
await this._checkReadOnly();
73+
}
7174
}
7275

7376
return error;
@@ -162,11 +165,11 @@ with open("${path}", "rb") as f:
162165
async _readTextFile(path) {
163166
try {
164167
let code = `
165-
with open("${path}", "r") as f:
166-
print(f.read())
167-
`;
168+
with open("${path}", "r") as f:
169+
print(f.read())
170+
`;
168171
let result = await this._repl.execRawPasteMode(code);
169-
if (this._checkReplErrors()) {
172+
if (await this._checkReplErrors()) {
170173
return null;
171174
}
172175

0 commit comments

Comments
 (0)