{ "info": { "author": "tjumyk", "author_email": "tjumyk@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: MIT License", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3" ], "description": "# PyQuota\n\nPyQuota is a simple python wrapper for C apis of [quotactl](http://man7.org/linux/man-pages/man2/quotactl.2.html).\n\nSupported kernel versions: `>=2.4.22, <5`.\n\nSupported commands in C APIs:\n\n- `Q_QUOTAON`\n- `Q_QUOTAOFF`\n- `Q_GETQUOTA`\n- `Q_GETNEXTQUOTA` (requires kernel >= 4.6)\n- `Q_SETQUOTA`\n- `Q_GETINFO`\n- `Q_SETINFO`\n- `Q_GETFMT`\n- `Q_SYNC`\n\nCurrently, none of the commands for XFS filesystem, e.g. `Q_XQUOTAON`, are supported due to lack of documentations and testing environments.\n\n## Installation\n\n```bash\npip install pyquota\n```\n\n## Usage \n\nFor each of the supported commands, as listed above, this package provides 3 Python methods, which corresponds to operations on user quotas, group quotas and project quotas. Project quota methods requires kernel >=4.1.\n\nFor illustration purpose, only examples of user quota methods are provided here. To use group/project quota methods, you only need to replace 'user' in the method names with 'group' or 'project'.\n\n```python\n# Import package\nimport pyquota as pq\n\n# Turn on user quota for a filesystem\npq.user_quota_on(\"/dev/sda1\", pq.QFMT_VFS_V0, \"/aquota.user\") # device path, quota format, quota file path \n# quota format can be either pq.QFMT_VFS_OLD, pq.QFMT_VFS_V0 or pq.QFMT_VFS_V1.\n\n# Turn off user quota for a filesystem\npq.user_quota_off(\"/dev/sda1\")\n\n# Get quota of a user on a filesystem\nquota = pq.get_user_quota(\"/dev/sda1\", 1000) # 1000 is the uid, returns a tuple of 8 integers\nblock_hard_limit = quota[0] # unit: disk quota block (1024 Bytes)\nblock_soft_limit = quota[1] # unit: disk quota block (1024 Bytes)\nblock_current = quota[2] # unit: block (1 Byte)\ninode_hard_limit = quota[3]\ninode_soft_limit = quota[4]\ninode_current = quota[5]\nblock_time = quota[6] # time limit for excessive disk use\ninode_time = quota[7] # time limit for excessive files\n\n# Get quota of the next user, whose ID is greater than or equal to the specified ID, on a filesystem\nquota = pq.get_next_user_quota(\"/dev/sda1\", 1000) # returns a tuple of 9 integers. \n# The first 8 integers are the same as the result of pg.get_user_quota while the last integer is the user id. \nuid = quota[8]\n\n# Set quota of a user on a filesystem\npq.set_user_quota(\"/dev/sda1\", 1000, 102400, 92160, 0, 0) # hard block limit 100MB, soft block limit 90MB, no inode limits \n\n# Get information about the user quotafile for a filesystem\ninfo = pq.get_user_quota_info(\"/dev/sda1\") # returns a tuple of 3 integers\nblock_grace = info[0] # time before block soft limit becomes hard limit. (unit: second)\ninode_grace = info[1] # time before inode soft limit becomes hard limit. (unit: second)\nflags = info[2] # flags for quotafile\nis_root_squash_enabled = bool(flags & pq.DQF_ROOT_SQUASH)\nis_stored_in_system_file = bool(flags & pq.DQF_SYS_FILE)\n\n# Set information about the user quotafile for a filesystem\npq.set_user_quota_info(\"/dev/sda1\", 604800, 604800, 0) # set both block grace and inode grace to 1 week (7*24*60*60), set flags as empty \n\n# Get quota format used for user quotas on a filesystem\nfmt = pq.get_user_quota_format(\"/dev/sda1\") # returns an integer \n# fmt should be either pq.QFMT_VFS_OLD, pq.QFMT_VFS_V0 or pq.QFMT_VFS_V1\n\n# Update the on-disk copy of user quota usages for a filesystem\npq.sync_user_quotas(\"/dev/sda1\")\n\n# Update the on-disk copy of user quota usages for all filesystems with active quotas\npq.sync_user_quotas(None)\n```\n\nSince this package is only a wrapper for the C APIs, it almost keeps the original flavor and input/output formats. Thus, if you want more details about the what each of these commands do, meaning of the arguments and meaning of the returned values, please read the [man page](http://man7.org/linux/man-pages/man2/quotactl.2.html). \n\n## Error Messages\n\nAny internal error that comes from the C apis is translated to a `pyquota.APIError` instance with a text description according to the [ERRORS section in the man page](http://man7.org/linux/man-pages/man2/quotactl.2.html#ERRORS).", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/tjumyk/pyquota", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "PyQuota", "package_url": "https://pypi.org/project/PyQuota/", "platform": "", "project_url": "https://pypi.org/project/PyQuota/", "project_urls": { "Homepage": "https://github.com/tjumyk/pyquota" }, "release_url": "https://pypi.org/project/PyQuota/0.0.3/", "requires_dist": null, "requires_python": "", "summary": "A simple python wrapper for C apis of quotactl", "version": "0.0.3" }, "last_serial": 5486702, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "8667e87e15310fe601ec2d32f42f00b4", "sha256": "63ddf163372e714276c528bdfe1d2c6cf6d18b2871a2d8210b8ac22e32539735" }, "downloads": -1, "filename": "PyQuota-0.0.1.tar.gz", "has_sig": false, "md5_digest": "8667e87e15310fe601ec2d32f42f00b4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4100, "upload_time": "2019-07-03T23:27:31", "url": "https://files.pythonhosted.org/packages/68/40/c7460a7708948b2464239ddbb2de176b3156d923ca934325fee7aa4799fc/PyQuota-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "e50ec9465253006b3b1564c984817347", "sha256": "9373ec9bda96d03f91198ffd908784e7577838fa1f993f00e8938a50cc4c1fa0" }, "downloads": -1, "filename": "PyQuota-0.0.2.tar.gz", "has_sig": false, "md5_digest": "e50ec9465253006b3b1564c984817347", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5655, "upload_time": "2019-07-04T02:29:07", "url": "https://files.pythonhosted.org/packages/3a/0c/74641a3d0464d8d02d940e6776fe538de05a68c00ffbe4168a4bf0c46f94/PyQuota-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "32dc8ca942d604a9af22f96246f656b6", "sha256": "cc45e0ef02100356b8d05d68ea5fdad93cd7ce99020fdc8c547945432a1409b7" }, "downloads": -1, "filename": "PyQuota-0.0.3.tar.gz", "has_sig": false, "md5_digest": "32dc8ca942d604a9af22f96246f656b6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5779, "upload_time": "2019-07-04T13:28:18", "url": "https://files.pythonhosted.org/packages/02/00/1a8016a8a5f7a30fef704020753db40694498ebe793ab58245907a3cf21c/PyQuota-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "32dc8ca942d604a9af22f96246f656b6", "sha256": "cc45e0ef02100356b8d05d68ea5fdad93cd7ce99020fdc8c547945432a1409b7" }, "downloads": -1, "filename": "PyQuota-0.0.3.tar.gz", "has_sig": false, "md5_digest": "32dc8ca942d604a9af22f96246f656b6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5779, "upload_time": "2019-07-04T13:28:18", "url": "https://files.pythonhosted.org/packages/02/00/1a8016a8a5f7a30fef704020753db40694498ebe793ab58245907a3cf21c/PyQuota-0.0.3.tar.gz" } ] }