permission denied deleting folder

The official PYBD running MicroPython, and its accessories.
Target audience: Users with a PYBD
Post Reply
MrRobot
Posts: 31
Joined: Mon May 11, 2020 11:30 am

permission denied deleting folder

Post by MrRobot » Wed Jun 17, 2020 3:57 pm

So I have the following code that I've been using to experiment with file system limits on my Pyboard D:

Code: Select all

import uos
import uerrno
import sys

uos.mkdir('test')

try:

    for x in range(10000000):

        try:
            uos.listdir('test')

        except Exception as e:
            print('Error indexing files: ',e)
            print('x:',x)
            uos.sync()
            sys.exit()

        filename = 'test/' + str(x) +'.json'

        with open(filename, "w") as file:

            file.write('testing of file system limits')

        uos.sync()

except Exception as e:

    print(e)
    print('Limit :',x)

Once this code has ran I have a folder called test that has loads of tester files in it.

When I enter the command :

Code: Select all

 os.rmdir('test') 
I get the following Error : OSError: [Errno 13] EACCES


Which has something to do with file permissions.

Anyone know why I can't delete this folder?

The only option I have is to mount it on my PC and manually delete the folder.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: permission denied deleting folder

Post by Roberthh » Wed Jun 17, 2020 5:20 pm

rmdir requires the folder to be empty. So you have to delete the files first. That' s what the PC software does under the hoid.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: permission denied deleting folder

Post by pythoncoder » Thu Jun 18, 2020 5:24 am

The files can be deleted in code, but I suggest you try rshell for communication with a Pyboard. I use it continuously. At the rshell prompt you can issue

Code: Select all

rm -r /sd/test
and the job is done. It supports many other useful features.
Peter Hinch
Index to my micropython libraries.

Post Reply