Skip to main content

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)
  • Create a DwarFS image file (mkdwarfs)
  • Extract a DwarFS image file (dwarfsextract)
  • 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')
CompletedProcess(args=['/usr/bin/dwarfs', '/path/to/source.dwarfs', '/path/to/destination/directory'], returncode=0)
>>>

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]
CompletedProcess(args=['/usr/bin/dwarfs', '/path/to/source.1.dwarfs', '/path/to/destination/directory.1', '-o', 'cachesize=32M', '-o', 'readonly', '-o', 'debuglevel=debug'], returncode=0)
>>>

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]
CompletedProcess(args=['/usr/bin/dwarfs', '/path/to/source.2.dwarfs', '/path/to/destination/directory.2', '-o', 'cachesize=16M', '-o', 'readonly', '-o', 'debuglevel=debug'], returncode=0)
>>>

Unmount

>>> dwarfs.unmount('/path/to/destination/directory')
CompletedProcess(args=['fusermount3', '-u', '/path/to/destination/directory'], returncode=0)
>>>

Unmount by the method umount instead of the default fusermount:

>>> dwarfs.unmount('/path/to/destination/directory.1', method='umount')
CompletedProcess(args=['umount', '/path/to/destination/directory.1'], returncode=0)
>>>

You can forcely unmount by add the argument lazy_unmount=True:

>>> dwarfs.unmount('/path/to/destination/directory.2', lazy_unmount=True)
CompletedProcess(args=['fusermount3', '-u', '-z', '/path/to/destination/directory.2'], returncode=0)
>>>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydwarfs-0.1.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

pydwarfs-0.1.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file pydwarfs-0.1.0.tar.gz.

File metadata

  • Download URL: pydwarfs-0.1.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for pydwarfs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e51259b56d98c8f733ef99ecc1127c8347fc0efb1eaa53677aae322ee3c91b89
MD5 e6416a2fe205b09cce60f20234086e3c
BLAKE2b-256 ca4b9e69eaa7b67be541b5b4c1a393c3ef7e9da629d1bb02fc033f141a08d884

See more details on using hashes here.

File details

Details for the file pydwarfs-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pydwarfs-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for pydwarfs-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e822584ed520caf244bb5408560baa6d9dbde9fef5fca3de035ae5d5d310ed43
MD5 27794cbd2d3d30b3276da1b7de50e5e8
BLAKE2b-256 87fded7fae1234289880a505dd451f2b4847eeea1ed5f71cc8a3cb3f01b8c7df

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page