I\'m simply trying to handle an uploaded file and write it in a working dir which name is the system timestamp. The problem is that I want to create that directory wi
For Unix systems (when the mode is not ignored) the provided mode is first masked with umask of current user. You could also fix the umask of the user that runs this code. Then you will not have to call os.chmod()
method.
Please note, that if you don't fix umask and create more than one directory with os.makedirs
method, you will have to identify created folders and apply os.chmod
on them.
For me I created the following function:
def supermakedirs(path, mode):
if not path or os.path.exists(path):
return []
(head, tail) = os.path.split(path)
res = supermakedirs(head, mode)
os.mkdir(path)
os.chmod(path, mode)
res += [path]
return res