Skip to main content

A package for reading, modifying, and writing U-Boot environment files

Project description

py-uboot-env

A Python package for manipulating U-Boot environment files with a modern API and convenient CLI tools.

PyPI version License

Overview

py-uboot-env provides functionality to read, modify, and write U-Boot environment files. It features both a programmer-friendly API and a versatile command-line interface.

Features

  • Command-line interface for common operations
  • Support for both file paths and file handles
  • Environment variable dependency analysis and visualization
  • Built-in environment editor with your system's default text editor

Installation

Install from PyPI:

pip install py-uboot-env

API Usage

Basic Usage

from py_uboot_env import load_env

# Load an environment file
env = load_env('/path/to/uboot.env')

# Read values
bootcmd = env.get('bootcmd')
bootdelay = env.get('bootdelay', '3')  # With default value

# Modify values
env.set('bootdelay', '5')
env.delete('unused_var')

# Save changes
env.save('/path/to/uboot.env')

Working with File Handles

from py_uboot_env import load_env, dump_env
import io

# Create an in-memory file-like object
buffer = io.BytesIO()

# Create a new environment and save it to the buffer
env = load_env(existing_env_file)
env.set('new_variable', 'value')
dump_env(env, buffer)

# Rewind the buffer and read it back
buffer.seek(0)
updated_env = load_env(buffer)

Command-Line Interface

py-uboot-env provides a single uboot-env command with multiple actions:

Viewing Environment Variables

# Dump the entire environment
uboot-env dump /path/to/uboot.env

# Get a specific variable
uboot-env get /path/to/uboot.env bootcmd

Modifying Environment Variables

# Set a variable
uboot-env set /path/to/uboot.env bootdelay 5

# Delete a variable
uboot-env delete /path/to/uboot.env unused_var

Interactive Editing

Open the environment file in your default text editor:

uboot-env edit /path/to/uboot.env

Dependency Analysis

Generate a GraphViz DOT representation of variable dependencies:

# Generate DOT output
uboot-env graph /path/to/uboot.env > uboot-deps.dot

# Generate a PDF using GraphViz (if installed)
uboot-env graph /path/to/uboot.env | dot -Tpdf -o uboot-deps.pdf

This analyzes which environment variables are read from, written to, or which commands are run by each variable, creating a visual dependency graph.

Environment File Format

The package handles U-Boot environment files in their standard binary format, including:

  • CRC32 checksums in the header
  • Support for different environment sizes
  • Proper handling of redundant environment blocks

Development

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Submit a pull request

License

This project is licensed under The Unlicense - see the LICENSE file for details.

Acknowledgments

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_uboot_env-0.1.0-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_uboot_env-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for py_uboot_env-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e8540f39a16c1bacec9ad6604329e7da79aac613e97f0ef61e912dfe38d33c86
MD5 91a4482589526a7ea0fa9be93e0efd5d
BLAKE2b-256 fdd4bc209a9b74062a2cb44f23c1d66f534e4b5ff6fd92e6477b774af38657d9

See more details on using hashes here.

Supported by

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