Access Permissions¶
This module provides a set of methods to check and manage the access permissions to several files and directories maintained by MusicDB.
AccessPermissions Class¶
- class musicdb.mdbapi.accesspermissions.AccessPermissions(config, rootdirectory='/')[source]¶
- Parameters
config – MusicDB configuration object
rootdirectory – When paths are give, they are all considered relative to this root directory (optional, default is
"/"
)
- EvaluateArtworkDirectory()[source]¶
This method checks if the artwork directory has the correct permissions.
- Returns
True
when the MusicDB has read and write access to that directory.
- EvaluateStateDirectory()[source]¶
This method checks if the state directory has the correct permissions.
- Returns
True
when the MusicDB has read and write access to that directory.
- EvaluateTasksDirectory()[source]¶
This method checks if the tasks directory has the correct permissions.
- Returns
True
when the MusicDB has read and write access to that directory.
- EvaluateUploadsDirectory()[source]¶
This method checks if the uploads directory has the correct permissions.
- Returns
True
when the MusicDB has read and write access to that directory.
- IsReadable(path)[source]¶
This method returns
True
when the file or directory addressed by path is readable. If it is directory, the read and execute flag is checked.- Parameters
path – A string, path-like object or a
Filesystem
object.- Returns
True
if the file or directory is readable, otherwiseFalse
Example
ac = AccessPermissions() ac.IsReadable("/etc/passwd") # False ac.IsReadable(Path("~")) # True musicdir = Filesystem("/var/music") ac.IsReadable(musicdir) # True
- IsWritable(path)[source]¶
This method returns
True
when the file or directory addressed by path is writable. If it is directory, the read and execute flag is checked. This method implies that the file or directory is not only writable but also readable.- Parameters
path – A string, path-like object or a
Filesystem
object.- Returns
True
if the file or directory is writable, otherwiseFalse
Example
ac = AccessPermissions() ac.IsWritable("/etc/passwd") # False ac.IsWritable(Path("~")) # True musicdir = Filesystem("/var/music") ac.IsWritable(musicdir) # True