Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions micropython.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
}
Expand Down
152 changes: 68 additions & 84 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.