Page 1 of 1

permission denied deleting folder

Posted: Wed Jun 17, 2020 3:57 pm
by MrRobot
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.

Re: permission denied deleting folder

Posted: Wed Jun 17, 2020 5:20 pm
by Roberthh
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.

Re: permission denied deleting folder

Posted: Thu Jun 18, 2020 5:24 am
by pythoncoder
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.