Documentation for the getdevinfo module

This is the part of the package that you would normally import and use. It detects your platform (Linux or macOS), and runs the correct tools for that platform.

For example:

>>> import getdevinfo
>>> getdevinfo.getdevinfo.get_info()

Or, more concisely:

>>> import getdevinfo.getdevinfo as getdevinfo
>>> getdevinfo.get_info()

Will run the correct tools for your platform and return the collected disk information as a dictionary.

Note

You can import the submodules directly, but this might result in strange behaviour, or not work on your platform if you import the wrong one. That is not how the package is intended to be used, except if you want to use the get_block_size() function to get a block size, as documented for each platform later.

getdevinfo.getdevinfo.get_info(name_main=False)

This function is used to determine the platform you’re using (Linux or macOS) and run the relevant tools. Then, it returns the disk information dictionary to the caller.

Returns:
dict, the disk info dictionary.
Raises:

Hopefully nothing, but if there is an unhandled error or bug elsewhere, there’s a small chance it could propagate to here. If this concerns you, you can wrap this code in a try:, except: clause:

>>> try:
>>>     get_info()
>>> except:
>>>     #Handle the error.

Usage:

>>> disk_info = get_info()
getdevinfo.getdevinfo.run()

Allows the module to be run with -m.