This is a simple wrapper for the
quotactl system call, allowing getting and setting quota directly from Python (no need to call an external program and parse its output).
It's still extremely primordial, providing limited functionality and working only with Linux quota version 2. It has been tested on Debian Etch and Lenny. As my first attempt to write a module it is also very far from elegance (and no pythonic at all).
To install the module you need the following steps (provided you have standard development tools installed):
svn co https://labs.truelite.it/svn/cyrcus/quotamodule cd quotamodule/ python setup.py build
then you can copy the
quota.so module (look inside the created build directory) to its destination (if you want to just check it with
python you can use your current working directory).
The module provides the following functions (interface is preliminar, it will be probably changed in future releases):
||get user quota|
||get group quota|
||set block user quota|
||set inode user quota|
||set block group quota|
||set inode group quota|
User or group can be only specified by numeric ID (uid or gid). The device string must be the device pathname for the filesystem on which we want to operate.
When setting quotas they must be provided as a tuple of two integer values (first for soft limit, second for hard limit). They will be applied to inode/block, user/group according to the chosen function.
Reading quota will give back a tuple of two dictionaries. First dictionary is for block quota data, second for inode quota data. Both dictionaries will have the same string keys according to the following table:
|used||integer with the actual usage of the resource (blocks or inodes number)|
|quota||a two integers tuple with the current value of the quota (soft limit, hard limit)|
|grace|| an integer with the
All error in calling the
quotactl function will raise an
OSError exception passing the error value in