mntfinder


Namemntfinder JSON
Version 1.0.0 PyPI version JSON
download
home_pageNone
SummaryParse /proc/mounts and find/list mountpoints (Not a wrapper of findmnt)
upload_time2024-05-25 17:08:26
maintainerNone
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

### List all mountpoints

```python
import mntfinder

for m in mntfinder.getAllMountPoints():
    print(f'{m.source!s} on {m.target!s} type {m.fstype!s} ({",".join(m.options)!s})')
```

Output:

```
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sys on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
dev on /dev type devtmpfs (rw,nosuid,relatime,size=6915412k,nr_inodes=1728853,mode=755,inode64)
run on /run type tmpfs (rw,nosuid,nodev,relatime,mode=755,inode64)
efivarfs on /sys/firmware/efi/efivars type efivarfs (rw,nosuid,nodev,noexec,relatime)
/dev/nvme1n1p3 on / type btrfs (rw,relatime,ssd,discard=async,space_cache=v2,subvolid=5,subvol=/)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,inode64)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,size=4096k,nr_inodes=1024,mode=755,inode64)
cgroup2 on /sys/fs/cgroup/unified type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
bpf on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,relatime,mode=700)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
cgroup on /sys/fs/cgroup/rdma type cgroup (rw,nosuid,nodev,noexec,relatime,rdma)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/misc type cgroup (rw,nosuid,nodev,noexec,relatime,misc)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=37,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=4467)
debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec,relatime)
mqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,noexec,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,nosuid,nodev,relatime,pagesize=2M)
tracefs on /sys/kernel/tracing type tracefs (rw,nosuid,nodev,noexec,relatime)
configfs on /sys/kernel/config type configfs (rw,nosuid,nodev,noexec,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,nosuid,nodev,noexec,relatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,size=6947940k,nr_inodes=1048576,inode64)
/dev/nvme1n1p5 on /var/lib/libvirt/images type btrfs (rw,relatime,ssd,discard=async,space_cache=v2,subvolid=257,subvol=/var/lib/libvirt/@images)
/dev/nvme1n1p2 on /boot type ext4 (rw,relatime)
/dev/nvme1n1p1 on /boot/efi type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,nosuid,nodev,noexec,relatime)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=1389584k,nr_inodes=347396,mode=700,uid=1000,gid=1000,inode64)
portal on /run/user/1000/doc type fuse.portal (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)
```

## Get a single mountpoint info

```python
import mntfinder

mntinfo_proc = mntfinder.getMountPoint('/proc')
print(f'{mntinfo_proc.source!s} on {mntinfo_proc.target!s} type {mntinfo_proc.fstype!s} ({",".join(mntinfo_proc.options)!s})')
```

Output:

```
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
```

## Check if a path is mountpoint or not

```python
import mntfinder

print('/sys is a mountpoint:', mntfinder.isAMountPoint('/sys'))
print('/mnt/nonexist is a mountpoint:', mntfinder.isAMountPoint('/mnt/nonexist'))
```

Output:

```
/sys is a mountpoint: True
/mnt/nonexist is a mountpoint: False
```

## Check if a mountpoint is still mounted

```python
import mntfinder
import subprocess

mnt = mntfinder.getMountPoint('/run/media/user/WindowsData')
print(f'{mnt.source!s} on {mnt.target!s} type {mnt.fstype!s} ({",".join(mnt.options)!s})')
print(f'{mnt.target!s} is still mounted: {mnt.isStillMounted()!s}')
subprocess.run(['udisksctl', 'unmount', '--block-device', mnt.source])
print(f'{mnt.target!s} is still mounted: {mnt.isStillMounted()!s}')
```

Output:

```
/dev/nvme0n1p3 on /run/media/user/WindowsData type ntfs3 (ro,nosuid,nodev,relatime,uid=1000,gid=1000,iocharset=utf8)
/run/media/user/WindowsData is still mounted: True
Unmounted /dev/nvme0n1p3.
/run/media/user/WindowsData is still mounted: False
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "mntfinder",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "mountpoint, mnt, findmnt",
    "author": "nukemiko",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/b0/5c/242072e86d34c3037e6573f93d29ebde2b11a963327e00103e9956c54a4a/mntfinder-1.0.0.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\n### List all mountpoints\n\n```python\nimport mntfinder\n\nfor m in mntfinder.getAllMountPoints():\n    print(f'{m.source!s} on {m.target!s} type {m.fstype!s} ({\",\".join(m.options)!s})')\n```\n\nOutput:\n\n```\nproc on /proc type proc (rw,nosuid,nodev,noexec,relatime)\nsys on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)\ndev on /dev type devtmpfs (rw,nosuid,relatime,size=6915412k,nr_inodes=1728853,mode=755,inode64)\nrun on /run type tmpfs (rw,nosuid,nodev,relatime,mode=755,inode64)\nefivarfs on /sys/firmware/efi/efivars type efivarfs (rw,nosuid,nodev,noexec,relatime)\n/dev/nvme1n1p3 on / type btrfs (rw,relatime,ssd,discard=async,space_cache=v2,subvolid=5,subvol=/)\nsecurityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)\ntmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,inode64)\ndevpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)\ntmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,size=4096k,nr_inodes=1024,mode=755,inode64)\ncgroup2 on /sys/fs/cgroup/unified type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)\ncgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,name=systemd)\npstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)\nbpf on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,relatime,mode=700)\ncgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)\ncgroup on /sys/fs/cgroup/rdma type cgroup (rw,nosuid,nodev,noexec,relatime,rdma)\ncgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)\ncgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)\ncgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)\ncgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)\ncgroup on /sys/fs/cgroup/misc type cgroup (rw,nosuid,nodev,noexec,relatime,misc)\ncgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)\ncgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)\ncgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)\ncgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)\ncgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)\nsystemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=37,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=4467)\ndebugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec,relatime)\nmqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,noexec,relatime)\nhugetlbfs on /dev/hugepages type hugetlbfs (rw,nosuid,nodev,relatime,pagesize=2M)\ntracefs on /sys/kernel/tracing type tracefs (rw,nosuid,nodev,noexec,relatime)\nconfigfs on /sys/kernel/config type configfs (rw,nosuid,nodev,noexec,relatime)\nfusectl on /sys/fs/fuse/connections type fusectl (rw,nosuid,nodev,noexec,relatime)\ntmpfs on /tmp type tmpfs (rw,nosuid,nodev,size=6947940k,nr_inodes=1048576,inode64)\n/dev/nvme1n1p5 on /var/lib/libvirt/images type btrfs (rw,relatime,ssd,discard=async,space_cache=v2,subvolid=257,subvol=/var/lib/libvirt/@images)\n/dev/nvme1n1p2 on /boot type ext4 (rw,relatime)\n/dev/nvme1n1p1 on /boot/efi type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)\nbinfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,nosuid,nodev,noexec,relatime)\ntmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=1389584k,nr_inodes=347396,mode=700,uid=1000,gid=1000,inode64)\nportal on /run/user/1000/doc type fuse.portal (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)\ngvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)\n```\n\n## Get a single mountpoint info\n\n```python\nimport mntfinder\n\nmntinfo_proc = mntfinder.getMountPoint('/proc')\nprint(f'{mntinfo_proc.source!s} on {mntinfo_proc.target!s} type {mntinfo_proc.fstype!s} ({\",\".join(mntinfo_proc.options)!s})')\n```\n\nOutput:\n\n```\nproc on /proc type proc (rw,nosuid,nodev,noexec,relatime)\n```\n\n## Check if a path is mountpoint or not\n\n```python\nimport mntfinder\n\nprint('/sys is a mountpoint:', mntfinder.isAMountPoint('/sys'))\nprint('/mnt/nonexist is a mountpoint:', mntfinder.isAMountPoint('/mnt/nonexist'))\n```\n\nOutput:\n\n```\n/sys is a mountpoint: True\n/mnt/nonexist is a mountpoint: False\n```\n\n## Check if a mountpoint is still mounted\n\n```python\nimport mntfinder\nimport subprocess\n\nmnt = mntfinder.getMountPoint('/run/media/user/WindowsData')\nprint(f'{mnt.source!s} on {mnt.target!s} type {mnt.fstype!s} ({\",\".join(mnt.options)!s})')\nprint(f'{mnt.target!s} is still mounted: {mnt.isStillMounted()!s}')\nsubprocess.run(['udisksctl', 'unmount', '--block-device', mnt.source])\nprint(f'{mnt.target!s} is still mounted: {mnt.isStillMounted()!s}')\n```\n\nOutput:\n\n```\n/dev/nvme0n1p3 on /run/media/user/WindowsData type ntfs3 (ro,nosuid,nodev,relatime,uid=1000,gid=1000,iocharset=utf8)\n/run/media/user/WindowsData is still mounted: True\nUnmounted /dev/nvme0n1p3.\n/run/media/user/WindowsData is still mounted: False\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": "1.0.0",
    "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": "d8f71277646c4fe9b5c2236c82a23f8481af8538bd47637949bdd1a9306db671",
                "md5": "aa9cb41e647ccdc980cd8b29a991959d",
                "sha256": "68a7fc1c64e8167b6822b6aa19402c580f9024ce286af22c8f0c7500eb0aea13"
            },
            "downloads": -1,
            "filename": "mntfinder-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "aa9cb41e647ccdc980cd8b29a991959d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 6171,
            "upload_time": "2024-05-25T17:08:24",
            "upload_time_iso_8601": "2024-05-25T17:08:24.893628Z",
            "url": "https://files.pythonhosted.org/packages/d8/f7/1277646c4fe9b5c2236c82a23f8481af8538bd47637949bdd1a9306db671/mntfinder-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b05c242072e86d34c3037e6573f93d29ebde2b11a963327e00103e9956c54a4a",
                "md5": "91da47a26b1862c2054a58ab0a203684",
                "sha256": "c081426a5c23f83816cd68e705f0a791525ee56e4c2927ea32950b912fb894a2"
            },
            "downloads": -1,
            "filename": "mntfinder-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "91da47a26b1862c2054a58ab0a203684",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 5704,
            "upload_time": "2024-05-25T17:08:26",
            "upload_time_iso_8601": "2024-05-25T17:08:26.660040Z",
            "url": "https://files.pythonhosted.org/packages/b0/5c/242072e86d34c3037e6573f93d29ebde2b11a963327e00103e9956c54a4a/mntfinder-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-25 17:08:26",
    "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.33359s