Merge pull request #3 from makermelissa/main
Fix Read Textfile bug and output python errors to console
This commit is contained in:
commit
5c5c33c744
3 changed files with 14 additions and 11 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@adafruit/circuitpython-repl-js",
|
||||
"version": "1.2.3",
|
||||
"version": "2.0.1",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@adafruit/circuitpython-repl-js",
|
||||
"version": "1.2.3",
|
||||
"version": "2.0.1",
|
||||
"license": "MIT",
|
||||
"devDependencies": {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
"publishConfig": {
|
||||
"registry": "https://npm.pkg.github.com"
|
||||
},
|
||||
"version": "1.2.3",
|
||||
"version": "2.0.1",
|
||||
"description": "A JavaScript Module to help with interfacing to the REPL on CircuitPython Devices over serial",
|
||||
"main": "repl.js",
|
||||
"exports": {
|
||||
|
|
|
|||
19
repl.js
19
repl.js
|
|
@ -64,10 +64,13 @@ export class FileOps {
|
|||
|
||||
async _checkReplErrors() {
|
||||
let error = this._repl.getErrorOutput();
|
||||
if (error && error.type == "OSError" && error.errno == 30) {
|
||||
this._isReadOnly = true;
|
||||
// Throw an error if needed
|
||||
await this._checkReadOnly();
|
||||
if (error) {
|
||||
console.error("Python Error - " + error.type + ": " + error.message);
|
||||
if (error.type == "OSError" && error.errno == 30) {
|
||||
this._isReadOnly = true;
|
||||
// Throw an error if needed
|
||||
await this._checkReadOnly();
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
|
|
@ -162,11 +165,11 @@ with open("${path}", "rb") as f:
|
|||
async _readTextFile(path) {
|
||||
try {
|
||||
let code = `
|
||||
with open("${path}", "r") as f:
|
||||
print(f.read())
|
||||
`;
|
||||
with open("${path}", "r") as f:
|
||||
print(f.read())
|
||||
`;
|
||||
let result = await this._repl.execRawPasteMode(code);
|
||||
if (this._checkReplErrors()) {
|
||||
if (await this._checkReplErrors()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue