Skip to content

Python development

Joachim Metz edited this page Jun 25, 2026 · 2 revisions

libvsmbr comes with Python-bindings named pyvsmbr.

Below are examples how use pyvsmbr. They assume you have a working version of pyvsmbr on your system. To build pyvsmbr see Building.

Import

To be able to use pyvsmbr in your Python scripts add the following import:

import pyvsmbr

Get version

The get_version() module function can be used to retrieve the version of the pyvsmbr.

pyvsmbr.get_version()

This will return a textual string (Unicode) that contains the libvsmbr version. Since pyvsmbr is a wrapper around libvsmbr it does not have a separate version.

Open volume

Open a volume by path

vsmbr_volume = pyvsmbr.volume()

vsmbr_volume.open("image.raw")

...

vsmbr_volume.close()

The explicit call to vsmbr_volume.close() is not required. Close only must be called once all operations on the volume have been completed.

Open a volume using a file-like object

file_object = open("image.raw", "rb")

vsmbr_volume = pyvsmbr.volume()

vsmbr_volume.open_file_object(file_object)

...

vsmbr_volume.close()

The explicit call to vsmbr_volume.close() is not required. Close only must be called once all operations on the volume have been completed and will not close the file-like object itself.

Also see

import pyvsmbr

help(pyvsmbr)
help(pyvsmbr.volume)

Clone this wiki locally