Python API to manage EFI Boot Entries
Project description
pyefiboot
Python Library to manage EFI Boot Entries
The aim of this library is to provide an API to the functionality of the efibootmgr (https://github.com/rhinstaller/efibootmgr)
application. This provides a programmatic mechanism to read and update the EFI Boot Variables, allowing scripting of tasks to
manage the EFI boot process.
[!NOTE]
The initial release is a straightforward read-only solution, effectively mimicking the features of efibootmgr and efibootmgr -v calls.
Installation
When complete, should be:
pip install pyefiboot
Seek information elsewhere about installing in a virtual environment
This library currently has no dependencies
Usage
Most work can be done via the BootManager class which reads and provides access to all Boot related EFI variables
Reading current Boot Entries
import pyefiboot
bootmgr = pyefiboot.BootManager()
bootmgr.update_from_efi()
Printing to screen
To get output similar to efibootmgr:
bootmgr.display()
To get output similar to efibootmgr -v:
bootmgr.display(verbose=True)
Reading the BootCurrent, BootNext, BootTimeout and BootOrder EFI Variables
import pyefiboot
cur = pyefiboot.BootCurrent()
# Integer value of the current EFI Boot Entry
x: int = cur.value
# String representation of the current EFI Boot Entry, four character hex number
y: str = cur.hex_value
# BootNext and BootTimeout have similar functionality to BootCurrent
ord = pyefiboot.BootOrder()
# List of integers mapping the current programmed order of EFI Boot Entries
x: list[int] = ord.value
# String representation of the current EFI Boot Entry order, displayed as comma separated string of four character hex numbers
y: str = ord.hex_value
Creation of any of the above four classes will raise an exception if the nominated EFI variable does not exist
Reading an EFI Boot Entry variable
import pathlib
import pyefiboot
entry1 = pyefiboot.BootEntry(efivar_name='Boot0001')
entry2 = pyefiboot.BootEntry(efivar_fullpath=pathlib.Path('/sys/firmware/efi/efivars/Boot0002-8be4df61-93ca-11d2-aa0d-00e098032b8c'))
# Print string representation of boot entry to screen
print(entry1)
# Print verbose string representation of boot entry to screen
print(entry1.verbose_str())
# String representation of Boot Entry Index, four character hex number
x: str = entry2.entry_num
# If the Boot Entry refers to an actual local kernel to boot, returns the string representing the kernel file name, otherwise None
y: str | None = entry2.kernel_file
Access to other variables within the BootEntry will be in future versions
Logging
All modules within pyefiboot support Python logging, enabling logging and an appropriate log level in your
application will allow these logs to be captured
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyefiboot-0.0.1.tar.gz.
File metadata
- Download URL: pyefiboot-0.0.1.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ea42a2a457dcc7d2326fd466bb7323a7add9d0f1470e7854dcfa858f8aec7f2
|
|
| MD5 |
afcecd72d7c4f00a0563f7a59356a067
|
|
| BLAKE2b-256 |
f43943650ec72d26b7c3f95354bcb64b67c35ee8d43f30f1494d99bf9ed51ae5
|
Provenance
The following attestation bundles were made for pyefiboot-0.0.1.tar.gz:
Publisher:
python-publish.yml on jason-but/pyefiboot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyefiboot-0.0.1.tar.gz -
Subject digest:
5ea42a2a457dcc7d2326fd466bb7323a7add9d0f1470e7854dcfa858f8aec7f2 - Sigstore transparency entry: 2167717468
- Sigstore integration time:
-
Permalink:
jason-but/pyefiboot@1a445cd840436b4425bf1d7a12d89c2300726864 -
Branch / Tag:
refs/tags/0.0.1 - Owner: https://github.com/jason-but
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@1a445cd840436b4425bf1d7a12d89c2300726864 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyefiboot-0.0.1-py3-none-any.whl.
File metadata
- Download URL: pyefiboot-0.0.1-py3-none-any.whl
- Upload date:
- Size: 20.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c173d7226e874b6e9f48cfc6e50f0cef3a08f9786f093f6a419165bdb999168e
|
|
| MD5 |
64a30bf8e1911358c2c78065cd6f2f76
|
|
| BLAKE2b-256 |
b0b00862c00fb95e9848b7b8b0f6d06fc0abc8055187fb510e17cc1497fe4516
|
Provenance
The following attestation bundles were made for pyefiboot-0.0.1-py3-none-any.whl:
Publisher:
python-publish.yml on jason-but/pyefiboot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyefiboot-0.0.1-py3-none-any.whl -
Subject digest:
c173d7226e874b6e9f48cfc6e50f0cef3a08f9786f093f6a419165bdb999168e - Sigstore transparency entry: 2167717487
- Sigstore integration time:
-
Permalink:
jason-but/pyefiboot@1a445cd840436b4425bf1d7a12d89c2300726864 -
Branch / Tag:
refs/tags/0.0.1 - Owner: https://github.com/jason-but
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@1a445cd840436b4425bf1d7a12d89c2300726864 -
Trigger Event:
release
-
Statement type: