From 726eaff08fdd66dbe7a08662b277a28d2852ac23 Mon Sep 17 00:00:00 2001 From: ubi de feo Date: Wed, 13 Aug 2025 08:46:03 +0200 Subject: [PATCH 1/3] Fixed empty file list. Updated os import. Signed-off-by: ubi de feo --- micropython.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/micropython.js b/micropython.js index 5bec72b..ac212f0 100644 --- a/micropython.js +++ b/micropython.js @@ -220,9 +220,9 @@ class MicroPythonBoard { async fs_ls(folderPath) { folderPath = folderPath || '' - let command = `import uos\n` + let command = `import os\n` command += `try:\n` - command += ` print(uos.listdir("${folderPath}"))\n` + command += ` print(os.listdir("${folderPath}"))\n` command += `except OSError:\n` command += ` print([])\n` await this.enter_raw_repl() @@ -238,16 +238,17 @@ class MicroPythonBoard { async fs_ils(folderPath) { folderPath = folderPath || '' folderPath = folderPath || '' - let command = `import uos\n` + let command = `import os\n` command += `try:\n` command += ` l=[]\n` - command += ` for f in uos.ilistdir("${folderPath}"):\n` + command += ` f=None\n` + command += ` for f in os.ilistdir("${folderPath}"):\n` command += ` l.append(list(f))\n` command += ` print(l)\n` command += `except OSError:\n` command += ` print([])\n` command += `del l\n` - command += `del f\n` + command += `if f:del f\n` await this.enter_raw_repl() let output = await this.exec_raw(command) await this.exit_raw_repl() @@ -340,7 +341,7 @@ class MicroPythonBoard { if (filePath) { await this.enter_raw_repl() const output = await this.exec_raw( - `import uos\nuos.mkdir('${filePath}')` + `import os\nos.mkdir('${filePath}')` ) await this.exit_raw_repl() return Promise.resolve(output) @@ -350,9 +351,9 @@ class MicroPythonBoard { async fs_rmdir(filePath) { if (filePath) { - let command = `import uos\n` + let command = `import os\n` command += `try:\n` - command += ` uos.rmdir("${filePath}")\n` + command += ` os.rmdir("${filePath}")\n` command += `except OSError:\n` command += ` print(0)\n` await this.enter_raw_repl() @@ -365,9 +366,9 @@ class MicroPythonBoard { async fs_rm(filePath) { if (filePath) { - let command = `import uos\n` + let command = `import os\n` command += `try:\n` - command += ` uos.remove("${filePath}")\n` + command += ` os.remove("${filePath}")\n` command += `except OSError:\n` command += ` print(0)\n` await this.enter_raw_repl() @@ -381,7 +382,7 @@ class MicroPythonBoard { if (oldFilePath && newFilePath) { await this.enter_raw_repl() const output = await this.exec_raw( - `import uos\nuos.rename('${oldFilePath}', '${newFilePath}')` + `import os\nos.rename('${oldFilePath}', '${newFilePath}')` ) return this.exit_raw_repl() } From 6530ddb3dd42083268f20ac17587b5a5adb93150 Mon Sep 17 00:00:00 2001 From: ubi de feo Date: Wed, 13 Aug 2025 10:35:02 +0200 Subject: [PATCH 2/3] Updated version number for next release if fix accepted. Signed-off-by: ubi de feo --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 62cae7b..38a1e61 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "micropython.js", - "version": "1.5.1", - "description": "Interpretation of pyboard.py in javascript", + "version": "1.5.2", + "description": "A JavaScript implementation of PyBoard.", "main": "micropython.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" From 6b0d1ee125d7d9ce0206bf993e1ac0ae22c5c451 Mon Sep 17 00:00:00 2001 From: ubi de feo Date: Wed, 13 Aug 2025 10:37:03 +0200 Subject: [PATCH 3/3] Revert "Updated version number for next release if fix accepted." This reverts commit 6530ddb3dd42083268f20ac17587b5a5adb93150. --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 38a1e61..62cae7b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "micropython.js", - "version": "1.5.2", - "description": "A JavaScript implementation of PyBoard.", + "version": "1.5.1", + "description": "Interpretation of pyboard.py in javascript", "main": "micropython.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1"