A wrapper of DwarFS command line utility
Project description
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.
Note: This project currently does not provide support for Windows version of DwarFS command line utility.
Features / TODO
- Mount/unmount a DwarFS image file to specified mountpoint (
dwarfs
/mount.dwarfs
) - 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
Create a DwarFS
instance
In the default case, Dwarfs.init()
will find the location of dwarfs
command via shutil.which()
.
>>> 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.
>>> from pydwarfs.dwarfs import DwarFS
>>> dwarfs = Dwarfs.init('/path/to/valid/dwarfs')
>>> dwarfs.executable
'/path/to/valid/dwarfs'
>>>
A simple mount
>>> 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:
$ > 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
:
>>> 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:
>>> 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
>>> dwarfs.unmount('/path/to/destination/directory')
>>>
Unmount by the method umount
instead of the default fusermount
:
>>> dwarfs.unmount('/path/to/destination/directory.1', method='umount')
>>>
You can forcely unmount by add the argument lazy_unmount=True
:
>>> dwarfs.unmount('/path/to/destination/directory.2', lazy_unmount=True)
>>>
Extract a DwarFS image file
A simple extraction
>>> 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
>>> 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', ...]
>>>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pydwarfs-0.2.1.tar.gz
.
File metadata
- Download URL: pydwarfs-0.2.1.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f0b300c34e3be29043c7f518ca24b8e2394e93302f1262874bc4bc384c9f193 |
|
MD5 | 4ee725186fd0453888c0967e520fb94f |
|
BLAKE2b-256 | 03d9bfa2b9fe5d5ad728919a7f7e21b89d71511b1a31d2ef2efd935af085aa94 |
File details
Details for the file pydwarfs-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: pydwarfs-0.2.1-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7fb6e263160c3ac8cc07a416e0d70b64f61a997d1b87c0d421fa65b8621ab85 |
|
MD5 | ffde6575a90fe1641b3506a8234761d0 |
|
BLAKE2b-256 | cb1d946125215752199ebc1437c4e3fad3f113a0b6f6165e9d5e4ed56213c734 |