mntfinder


Namemntfinder JSON
Version 0.1.1 PyPI version JSON
download
home_page
SummaryParse /proc/mounts and find/list mountpoints (Not a wrapper of findmnt)
upload_time2024-01-07 18:58:58
maintainer
docs_urlNone
authornukemiko
requires_python>=3.10
licenseMIT License Copyright (c) 2024 Nukemiko<https://github.com/nukemiko> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords mountpoint mnt findmnt
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # mntfinder

Parse /proc/mounts and find/list mountpoints.

This project **IS NOT** a wrapper of `findmnt`.

## Install

Just run the command: `pip install mntfinder`.

Or you can download and install the wheel file from release page manually.

## Examples

All functions shown below can search for mountpoints in `/proc/<pid>/mounts` via the keyword argument `pid`. If not specified `pid`, these functions will search in `/proc/mounts` (it is usually linked to `/proc/self/mounts`.)

### `mntfinder.findMountPointByTarget(target: str | bytes | os.PathLike, *, pid: int | None = None) -> MountPoint | None`

```python
import mntfinder

mountpoint = mntfinder.findMountPointByTarget('/mnt/data')
if mountpoint:
    print(f"Mount point found: {mountpoint.source} -> {mountpoint.target} (Filesystem type: {mountpoint.fstype})")
else:
    print("Mount point not found")
```

### `mntfinder.listAllMountPoints(*, source: str | None = None, target: str | bytes | os.PathLike | None = None, fstype: str | None = None, pid: int | None = None) -> list[MountPoint]`

#### Retrieve all mount points

```python
import mntfinder

mountpoints = mntfinder.listAllMountPoints()
```

#### Retrieve mount points with a specific source

```python
import mntfinder

mountpoints = mntfinder.listAllMountPoints(source='/dev/sda1')
```

#### Retrieve mount points with a specific target

```python
import mntfinder

mountpoints = mntfinder.listAllMountPoints(target='/mnt/data')
```

#### Retrieve mount points with a specific file system type

```python
import mntfinder

mountpoints = mntfinder.listAllMountPoints(fstype='ext4')
```

### `mntfinder.isMountPoint(target: str | bytes | os.PathLike, *, source: str | None = None, fstype: str | None = None, pid: int | None = None) -> bool`

```python
import mntfinder

is_mount = mntfinder.isMountPoint('/mnt/data', source='/dev/sdb1', fstype='ext4')
if is_mount:
    print('/mnt/data is a mountpoint')
else:
    print('/mnt/data is not a mountpoint')
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "mntfinder",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "mountpoint,mnt,findmnt",
    "author": "nukemiko",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/5c/62/d178d010745500447c624521aa8035f3494fc976e1eefa76f60dfccf1b1e/mntfinder-0.1.1.tar.gz",
    "platform": null,
    "description": "# mntfinder\n\nParse /proc/mounts and find/list mountpoints.\n\nThis project **IS NOT** a wrapper of `findmnt`.\n\n## Install\n\nJust run the command: `pip install mntfinder`.\n\nOr you can download and install the wheel file from release page manually.\n\n## Examples\n\nAll functions shown below can search for mountpoints in `/proc/<pid>/mounts` via the keyword argument `pid`. If not specified `pid`, these functions will search in `/proc/mounts` (it is usually linked to `/proc/self/mounts`.)\n\n### `mntfinder.findMountPointByTarget(target: str | bytes | os.PathLike, *, pid: int | None = None) -> MountPoint | None`\n\n```python\nimport mntfinder\n\nmountpoint = mntfinder.findMountPointByTarget('/mnt/data')\nif mountpoint:\n    print(f\"Mount point found: {mountpoint.source} -> {mountpoint.target} (Filesystem type: {mountpoint.fstype})\")\nelse:\n    print(\"Mount point not found\")\n```\n\n### `mntfinder.listAllMountPoints(*, source: str | None = None, target: str | bytes | os.PathLike | None = None, fstype: str | None = None, pid: int | None = None) -> list[MountPoint]`\n\n#### Retrieve all mount points\n\n```python\nimport mntfinder\n\nmountpoints = mntfinder.listAllMountPoints()\n```\n\n#### Retrieve mount points with a specific source\n\n```python\nimport mntfinder\n\nmountpoints = mntfinder.listAllMountPoints(source='/dev/sda1')\n```\n\n#### Retrieve mount points with a specific target\n\n```python\nimport mntfinder\n\nmountpoints = mntfinder.listAllMountPoints(target='/mnt/data')\n```\n\n#### Retrieve mount points with a specific file system type\n\n```python\nimport mntfinder\n\nmountpoints = mntfinder.listAllMountPoints(fstype='ext4')\n```\n\n### `mntfinder.isMountPoint(target: str | bytes | os.PathLike, *, source: str | None = None, fstype: str | None = None, pid: int | None = None) -> bool`\n\n```python\nimport mntfinder\n\nis_mount = mntfinder.isMountPoint('/mnt/data', source='/dev/sdb1', fstype='ext4')\nif is_mount:\n    print('/mnt/data is a mountpoint')\nelse:\n    print('/mnt/data is not a mountpoint')\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Nukemiko<https://github.com/nukemiko>  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Parse /proc/mounts and find/list mountpoints (Not a wrapper of findmnt)",
    "version": "0.1.1",
    "project_urls": {
        "Changelog": "https://github.com/nukemiko/python-mntfinder/blob/master/CHANGELOG.md",
        "Issues": "https://github.com/nukemiko/python-mntfinder/issues",
        "Repository": "https://github.com/nukemiko/python-mntfinder"
    },
    "split_keywords": [
        "mountpoint",
        "mnt",
        "findmnt"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c947798b064c77f5bd65be11899ad37302ccf302e871b652b234b60560c06219",
                "md5": "f0032570c1ba58b984580669c0c95bef",
                "sha256": "033bd0cd43699d4808d51c93c2e57d1a535bdac3a9550caa97eacb868471c459"
            },
            "downloads": -1,
            "filename": "mntfinder-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f0032570c1ba58b984580669c0c95bef",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 5270,
            "upload_time": "2024-01-07T18:58:56",
            "upload_time_iso_8601": "2024-01-07T18:58:56.521836Z",
            "url": "https://files.pythonhosted.org/packages/c9/47/798b064c77f5bd65be11899ad37302ccf302e871b652b234b60560c06219/mntfinder-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5c62d178d010745500447c624521aa8035f3494fc976e1eefa76f60dfccf1b1e",
                "md5": "17a6487f609972b312321f0ddae372e6",
                "sha256": "7f51d74edaf6f18989ca66a58c2c5bef2ee208e210c0ce67623323de3b9e5526"
            },
            "downloads": -1,
            "filename": "mntfinder-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "17a6487f609972b312321f0ddae372e6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 4636,
            "upload_time": "2024-01-07T18:58:58",
            "upload_time_iso_8601": "2024-01-07T18:58:58.188305Z",
            "url": "https://files.pythonhosted.org/packages/5c/62/d178d010745500447c624521aa8035f3494fc976e1eefa76f60dfccf1b1e/mntfinder-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-07 18:58:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "nukemiko",
    "github_project": "python-mntfinder",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "mntfinder"
}
        
Elapsed time: 0.30643s