Reputation: 39
I'm converting some bash/shell scripts to Python. I'd like to only create a directory/folder on a CentOS system if it doesn't exist already and then set 777 permissions on it.
I can easily do this with one command in bash:
mkdir -m 777 "/PATH/TO/DIRECTORY/GOES/HERE";
Right now i'm running this command as a subprocess in python, but I was wondering if there was a cleaner, faster, and/or more efficient way of doing it?
Any help or even hits will be appreciated! :)
Upvotes: 0
Views: 130
Reputation: 7821
You can set the permissions directly when using os.mkdir:
mkdir(...)
mkdir(path [, mode=0777])
Create a directory.
Upvotes: 3