This class allows you to do advanced operations on filesystem directories, think of it as mkdir on steroids.
We advise you to use it as a context manager:
with Directory("/funky/path", mode=0o0700) as directory:
path = os.path.join(directory.path, "my-dir")
The directory is being removed once leaving the context. You can also easily do it on your own:
directory = Directory("/funky/path", mode=0o0700)
try:
directory.initialize()
finally:
directory.clean()
This class utilizes CLI tools to perform some operations. If some of them is missing, the exception is raised.
For more info on SELinux, please see $ man chcon. An exception will be thrown if selinux_context is specified and at least one of other SELinux fields.
Parameters: |
|
---|
remove the directory we operated on
Returns: | None |
---|
create the directory if needed and configure it
Returns: | None |
---|