Skip to content

Python development

Joachim Metz edited this page Jul 15, 2022 · 2 revisions

libvshadow comes with Python-bindings named pyvshadow.

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

Import

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

import pyvshadow

Get version

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

pyvshadow.get_version()

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

Open volume

Open a volume by path

vshadow_volume = pyvshadow.volume()

vshadow_volume.open("image.raw")

...

vshadow_volume.close()

The explicit call to vshadow_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")

vshadow_volume = pyvshadow.volume()

vshadow_volume.open_file_object(file_object)

...

vshadow_volume.close()

The explicit call to vshadow_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 pyvshadow

help(pyvshadow)
help(pyvshadow.volume)
Clone this wiki locally