Name | pydwarfs JSON |
Version |
0.3.1
JSON |
| download |
home_page | |
Summary | A wrapper of DwarFS command line utility |
upload_time | 2024-01-07 19:20:12 |
maintainer | |
docs_url | None |
author | nukemiko |
requires_python | >=3.10 |
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. |
keywords |
dwarfs
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# PyDwarfs
A wrapper of DwarFS command line utilities.
DwarFS is stands for **Deduplicating Warp-speed Advanced Read-only File System**, it is a fast high compression read-only file system for Linux and Windows. [See this project's homepage.](https://github.com/mhx/dwarfs)
**Note: This project currently does not provide support for Windows version of DwarFS command line utility.**
## Features / TODO
- [x] Mount/unmount a DwarFS image file to specified mountpoint (`dwarfs`/`mount.dwarfs`)
- [x] Extract a DwarFS image file (`dwarfsextract`, initially implemented)
- [ ] Create a DwarFS image file (`mkdwarfs`)
- [ ] Check a DwarFS image file (`dwarfsck`)
- [ ] Performance test (`dwarfsbench`)
## Install
Just run the command: `pip install pydwarfs`.
Or you can download and install the wheel file from release page manually.
## Examples
The following examples are for the more common uses of command line utilities.
### Mount/unmount a DwarFS image file to specified mountpoint
#### Check if a path is a DwarFS mountpoint
```pycon
>>> from pydwarfs.dwarfs import DwarFS
>>> DwarFS.isDwarFSMountPoint(this_is_dwarfs_mnt)
True
>>> DwarFS.isDwarFSMountPoint('/path/to/non-mnt')
False
>>> DwarFS.isDwarFSMountPoint('/proc') # Obviously not a DwarFS mountpoint
False
>>>
```
#### List all of DwarFS mountpoint
```pycon
>>> DwarFS.listAllDwarFSMountPoints()
[MountPoint(source='dwarfs', target=PosixPath('/path/to/dwarfs/image/mountpoint'), fstype='fuse.dwarfs', options=('rw', 'nosuid', 'nodev', 'relatime', 'user_id=1000', 'group_id=1000'), freq=0, passno=0), ...]
>>>
```
#### Create a `DwarFS` instance
In the default case, `Dwarfs.init()` will find the location of `dwarfs` command via `shutil.which()`.
```pycon
>>> from pydwarfs.dwarfs import DwarFS
>>> dwarfs = Dwarfs.init()
>>> dwarfs.executable
'/usr/bin/dwarfs'
>>>
```
If the DwarFS command line utilities are not installed, you can specify a location of `dwarfs` command instead.
```pycon
>>> from pydwarfs.dwarfs import DwarFS
>>> dwarfs = Dwarfs.init('/path/to/valid/dwarfs')
>>> dwarfs.executable
'/path/to/valid/dwarfs'
>>>
```
#### A simple mount
```pycon
>>> dwarfs.mount('/path/to/source.dwarfs', '/path/to/destination/directory')
>>>
```
To check if the mount was actually successful, exit the Python REPL and run the following command:
```sh-session
$ > findmnt /path/to/destination/directory
TARGET SOURCE FSTYPE OPTIONS
/path/to/destination/directory dwarfs fuse.dwarfs rw,nosuid,nodev,relatime,user_id=1000,group_id=1000
$ >
```
#### Mount with some specified options
Use the dedicated attribute class `DwarFSMountOptions`:
```pycon
>>> from pydwarfs.dwarfs import DwarFS, DwarFSMountOptions
>>> dwarfs = Dwarfs.init()
>>> options1 = DwarFSMountOptions(cachefile='32M', readonly=True, debuglevel='debug')
>>> dwarfs.mount('/path/to/source.1.dwarfs', '/path/to/destination/directory.1', options)
I 04:06:32.182380 [dwarfs_main.cpp:1328] dwarfs (v0.7.4, fuse version 35)
D 04:06:32.182909 [filesystem_v2.cpp:482] found valid section index
D 04:06:32.182927 [filesystem_v2.cpp:493] section BLOCK @ 64 [16,669,939 bytes]
...
D 04:06:32.191025 [filesystem_v2.cpp:515] read 734 blocks and 175,158 bytes of metadata
I 04:06:32.191041 [dwarfs_main.cpp:1144] file system initialized [8.624ms]
>>>
```
Or simply specify options by dict and **kwargs:
```pycon
>>> from pydwarfs.dwarfs import DwarFS, DwarFSMountOptions
>>> dwarfs = Dwarfs.init()
>>> options2 = {'cachefile': '16M', 'readonly': True}
>>> dwarfs.mount('/path/to/source.2.dwarfs', '/path/to/destination/directory.2', options, debuglevel='debug')
I 04:14:01.981335 [dwarfs_main.cpp:1328] dwarfs (v0.7.4, fuse version 35)
D 04:14:01.983736 [filesystem_v2.cpp:482] found valid section index
D 04:14:01.983753 [filesystem_v2.cpp:493] section BLOCK @ 64 [67,097,028 bytes]
...
D 04:14:01.984644 [filesystem_v2.cpp:515] read 7 blocks and 2,755 bytes of metadata
I 04:14:01.984656 [dwarfs_main.cpp:1144] file system initialized [3.27ms]
>>>
```
#### Unmount
```pycon
>>> dwarfs.unmount('/path/to/destination/directory')
>>>
```
Unmount by the method `umount` instead of the default `fusermount`:
```pycon
>>> dwarfs.unmount('/path/to/destination/directory.1', method='umount')
>>>
```
You can forcely unmount by add the argument `lazy_unmount=True`:
```pycon
>>> dwarfs.unmount('/path/to/destination/directory.2', lazy_unmount=True)
>>>
```
### Extract a DwarFS image file
#### A simple extraction
```pycon
>>> import os
>>> from pydwarfs.dwarfsextract import DwarFSExtract
>>> dwarfsextract = DwarFSExtract.init()
>>> output_dir = '/path/to/dest/directory'
>>> dwarfsextract.extract('/path/to/image.dwarfs', output_dir)
>>>
>>> os.listdir(output_dir)
['dataWin', 'Sakuna.exe', 'steam_appid.txt', 'xaudio2_9redist.dll', ...]
>>>
```
**Note:** The path pointed to by `output_dir` must be an existing directory.
#### Extract image file with progress
```pycon
>>> another_output_dir = '/path/to/another/output/directory'
>>> for progress in dwarfsextract.extract('/path/to/image.dwarfs', another_output_dir, yield_progress=True):
... print(progress)
...
100
99
98
...
2
1
0
>>> os.listdir(another_output_dir)
['dataWin', 'Sakuna.exe', 'steam_appid.txt', 'xaudio2_9redist.dll', ...]
>>>
```
Raw data
{
"_id": null,
"home_page": "",
"name": "pydwarfs",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "",
"keywords": "dwarfs",
"author": "nukemiko",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/04/76/cec7c56f567be2cd4341e1f8a131c5421e66e1b31683844da4944bac0664/pydwarfs-0.3.1.tar.gz",
"platform": null,
"description": "# PyDwarfs\n\nA wrapper of DwarFS command line utilities.\n\nDwarFS is stands for **Deduplicating Warp-speed Advanced Read-only File System**, it is a fast high compression read-only file system for Linux and Windows. [See this project's homepage.](https://github.com/mhx/dwarfs)\n\n**Note: This project currently does not provide support for Windows version of DwarFS command line utility.**\n\n## Features / TODO\n\n- [x] Mount/unmount a DwarFS image file to specified mountpoint (`dwarfs`/`mount.dwarfs`)\n- [x] Extract a DwarFS image file (`dwarfsextract`, initially implemented)\n- [ ] Create a DwarFS image file (`mkdwarfs`)\n- [ ] Check a DwarFS image file (`dwarfsck`)\n- [ ] Performance test (`dwarfsbench`)\n\n## Install\n\nJust run the command: `pip install pydwarfs`.\n\nOr you can download and install the wheel file from release page manually.\n\n## Examples\n\nThe following examples are for the more common uses of command line utilities.\n\n### Mount/unmount a DwarFS image file to specified mountpoint\n\n#### Check if a path is a DwarFS mountpoint\n\n```pycon\n>>> from pydwarfs.dwarfs import DwarFS\n>>> DwarFS.isDwarFSMountPoint(this_is_dwarfs_mnt)\nTrue\n>>> DwarFS.isDwarFSMountPoint('/path/to/non-mnt')\nFalse\n>>> DwarFS.isDwarFSMountPoint('/proc') # Obviously not a DwarFS mountpoint\nFalse\n>>>\n```\n\n#### List all of DwarFS mountpoint\n\n```pycon\n>>> DwarFS.listAllDwarFSMountPoints()\n[MountPoint(source='dwarfs', target=PosixPath('/path/to/dwarfs/image/mountpoint'), fstype='fuse.dwarfs', options=('rw', 'nosuid', 'nodev', 'relatime', 'user_id=1000', 'group_id=1000'), freq=0, passno=0), ...]\n>>>\n```\n\n#### Create a `DwarFS` instance\n\nIn the default case, `Dwarfs.init()` will find the location of `dwarfs` command via `shutil.which()`.\n\n```pycon\n>>> from pydwarfs.dwarfs import DwarFS\n>>> dwarfs = Dwarfs.init()\n>>> dwarfs.executable\n'/usr/bin/dwarfs'\n>>>\n```\n\nIf the DwarFS command line utilities are not installed, you can specify a location of `dwarfs` command instead.\n\n```pycon\n>>> from pydwarfs.dwarfs import DwarFS\n>>> dwarfs = Dwarfs.init('/path/to/valid/dwarfs')\n>>> dwarfs.executable\n'/path/to/valid/dwarfs'\n>>>\n```\n\n#### A simple mount\n\n```pycon\n>>> dwarfs.mount('/path/to/source.dwarfs', '/path/to/destination/directory')\n>>>\n```\n\nTo check if the mount was actually successful, exit the Python REPL and run the following command:\n\n```sh-session\n$ > findmnt /path/to/destination/directory\nTARGET SOURCE FSTYPE OPTIONS\n/path/to/destination/directory dwarfs fuse.dwarfs rw,nosuid,nodev,relatime,user_id=1000,group_id=1000\n$ >\n```\n\n#### Mount with some specified options\n\nUse the dedicated attribute class `DwarFSMountOptions`:\n\n```pycon\n>>> from pydwarfs.dwarfs import DwarFS, DwarFSMountOptions\n>>> dwarfs = Dwarfs.init()\n>>> options1 = DwarFSMountOptions(cachefile='32M', readonly=True, debuglevel='debug')\n>>> dwarfs.mount('/path/to/source.1.dwarfs', '/path/to/destination/directory.1', options)\nI 04:06:32.182380 [dwarfs_main.cpp:1328] dwarfs (v0.7.4, fuse version 35)\nD 04:06:32.182909 [filesystem_v2.cpp:482] found valid section index\nD 04:06:32.182927 [filesystem_v2.cpp:493] section BLOCK @ 64 [16,669,939 bytes]\n...\nD 04:06:32.191025 [filesystem_v2.cpp:515] read 734 blocks and 175,158 bytes of metadata\nI 04:06:32.191041 [dwarfs_main.cpp:1144] file system initialized [8.624ms]\n>>>\n```\n\nOr simply specify options by dict and **kwargs:\n\n```pycon\n>>> from pydwarfs.dwarfs import DwarFS, DwarFSMountOptions\n>>> dwarfs = Dwarfs.init()\n>>> options2 = {'cachefile': '16M', 'readonly': True}\n>>> dwarfs.mount('/path/to/source.2.dwarfs', '/path/to/destination/directory.2', options, debuglevel='debug')\nI 04:14:01.981335 [dwarfs_main.cpp:1328] dwarfs (v0.7.4, fuse version 35)\nD 04:14:01.983736 [filesystem_v2.cpp:482] found valid section index\nD 04:14:01.983753 [filesystem_v2.cpp:493] section BLOCK @ 64 [67,097,028 bytes]\n...\nD 04:14:01.984644 [filesystem_v2.cpp:515] read 7 blocks and 2,755 bytes of metadata\nI 04:14:01.984656 [dwarfs_main.cpp:1144] file system initialized [3.27ms]\n>>>\n```\n\n#### Unmount\n\n```pycon\n>>> dwarfs.unmount('/path/to/destination/directory')\n>>>\n```\n\nUnmount by the method `umount` instead of the default `fusermount`:\n\n```pycon\n>>> dwarfs.unmount('/path/to/destination/directory.1', method='umount')\n>>>\n```\n\nYou can forcely unmount by add the argument `lazy_unmount=True`:\n\n```pycon\n>>> dwarfs.unmount('/path/to/destination/directory.2', lazy_unmount=True)\n>>>\n```\n\n### Extract a DwarFS image file\n\n#### A simple extraction\n\n```pycon\n>>> import os\n>>> from pydwarfs.dwarfsextract import DwarFSExtract\n>>> dwarfsextract = DwarFSExtract.init()\n>>> output_dir = '/path/to/dest/directory'\n>>> dwarfsextract.extract('/path/to/image.dwarfs', output_dir)\n>>>\n>>> os.listdir(output_dir)\n['dataWin', 'Sakuna.exe', 'steam_appid.txt', 'xaudio2_9redist.dll', ...]\n>>>\n```\n\n**Note:** The path pointed to by `output_dir` must be an existing directory.\n\n#### Extract image file with progress\n\n```pycon\n>>> another_output_dir = '/path/to/another/output/directory'\n>>> for progress in dwarfsextract.extract('/path/to/image.dwarfs', another_output_dir, yield_progress=True):\n... print(progress)\n...\n100\n99\n98\n...\n2\n1\n0\n>>> os.listdir(another_output_dir)\n['dataWin', 'Sakuna.exe', 'steam_appid.txt', 'xaudio2_9redist.dll', ...]\n>>>\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": "A wrapper of DwarFS command line utility",
"version": "0.3.1",
"project_urls": {
"Changelog": "https://github.com/nukemiko/pydwarfs/blob/master/CHANGELOG.md",
"Issues": "https://github.com/nukemiko/pydwarfs/issues",
"Repository": "https://github.com/nukemiko/pydwarfs"
},
"split_keywords": [
"dwarfs"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "af93152c0001c8033fb8a0469b4de0fec358f2a8f022b2d23599f1c1927710c8",
"md5": "764f739b571c1e31bccec4f0d0f04b1e",
"sha256": "2df6b0da7b9103cf3a895b85dbe4429c177b1ec38609ca062e7f1b6ad081c0fb"
},
"downloads": -1,
"filename": "pydwarfs-0.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "764f739b571c1e31bccec4f0d0f04b1e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 10410,
"upload_time": "2024-01-07T19:20:10",
"upload_time_iso_8601": "2024-01-07T19:20:10.789028Z",
"url": "https://files.pythonhosted.org/packages/af/93/152c0001c8033fb8a0469b4de0fec358f2a8f022b2d23599f1c1927710c8/pydwarfs-0.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0476cec7c56f567be2cd4341e1f8a131c5421e66e1b31683844da4944bac0664",
"md5": "022e5155b6a9404116ebbc86537320a6",
"sha256": "7131c4e22a2ef775c7ac6d17863a0552680d2b2d0bf294f2805d5b2812e2561a"
},
"downloads": -1,
"filename": "pydwarfs-0.3.1.tar.gz",
"has_sig": false,
"md5_digest": "022e5155b6a9404116ebbc86537320a6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 10746,
"upload_time": "2024-01-07T19:20:12",
"upload_time_iso_8601": "2024-01-07T19:20:12.180601Z",
"url": "https://files.pythonhosted.org/packages/04/76/cec7c56f567be2cd4341e1f8a131c5421e66e1b31683844da4944bac0664/pydwarfs-0.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-07 19:20:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "nukemiko",
"github_project": "pydwarfs",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "pydwarfs"
}