Are there any Python modules that will let me get access to NFS quota information without having to parse the output of the quota command? I am aware that if I were sufficiently motivated I could write my own ONC/RPC code using Python’s xdrlib module, but I am hoping with all my heart that I do not have to get that intimately involved with the innards of NFS.
Ideally, I am hoping for an existing RPC implementation, or some higher-level module (like a wrapper for an existing C library or something).
An acceptable substitute would be something like the quota command that produces more machine-readable output.
This question was spawned originally by problems with version 3.13 of the
quotacommand, which is essentially useless as a tool for the end user to determine quota information. For example, ifalicerunsquota, she might see output like this:Alice would rightly wonder what this had to do with her account.
It turns out that the minds behind the
quota-utilspackage at long last realized the problems inherent in the tool; with version 4.00 (available in Fedora 16) there are several new options available that turn thequotacommand into something that actually produces useful information.Of particular interest is the
-foption:So now, a user can run:
And get the quota information for their home directory. Additionally, the
-soption will display “human readable” numbers instead of displaying everything as blocks.For Alice, this might look like:
Additionally, there are two options that make it much easier to process the output from
quotain a script:-woption inhibits the line wrapping when the “filesystem” name is too long.-poption displays0for the grace time if the user is not in an over-quota situation. This means that there are always the same number of fields (whereas with the previous version ofquotathe number of fields could vary depending on the situation).Combining all of the above, we get something like this:
Which is much more useful for automation.