Skip to main content

DrivePy

DrivePy is a Python package for managing USB drives, flashing ISO files to USB drives, and verifying bootability.

Installation

You can install DrivePy using pip:

pip install drivepy

Usage

Flash ISO to USB Drive and Make it Bootable

from drivepy.main import DrivePy

iso_path = "path/to/your/iso_file.iso"
usb_drive = "drive_letter_of_your_usb_drive"  # Example: "E:" on Windows, "/dev/sdb" on Linux

DrivePy.flash_iso(iso_path, usb_drive)
DrivePy.make_bootable(usb_drive)

Verify Bootability of a USB Drive

from drivepy.main import DrivePy

usb_drive = "drive_letter_of_your_usb_drive"  # Example: "E:" on Windows, "/dev/sdb" on Linux

DrivePy.verify_bootability(usb_drive)

List Available USB Drives

from drivepy.main import DrivePy

DrivePy.main()

Example Script

from drivepy.main import DrivePy

def flash_iso_and_boot(iso_path, usb_drive):
    # Flash ISO to USB drive
    DrivePy.flash_iso(iso_path, usb_drive)
    print("ISO flashed to USB drive successfully.")

    # Make the USB drive bootable
    DrivePy.make_bootable(usb_drive)
    print("USB drive made bootable successfully.")

    print("Connect the USB drive to your laptop and restart your laptop to boot from it.")

def verify_bootability(usb_drive):
    # Check if USB drive is bootable
    bootable = DrivePy.is_bootable(usb_drive)
    if bootable:
        print(f"The USB drive ({usb_drive}) is bootable.")
    else:
        print(f"The USB drive ({usb_drive}) is not bootable.")

def find_usb_drives():
    # Find available USB drives
    usb_drives = DrivePy.list_usb_drives()
    if not usb_drives:
        print("No USB drives detected.")
    else:
        print("Available USB drives:")
        for idx, drive in enumerate(usb_drives, 1):
            print(f"{idx}: {drive}")

def main():
    print("Welcome to DrivePy!")
    while True:
        print("\nChoose an option:")
        print("1. Flash ISO to USB drive and make it bootable")
        print("2. Verify bootability of a USB drive")
        print("3. Find available USB drives")
        print("4. Exit")
        choice = input("Enter your choice (1/2/3/4): ")

        if choice == '1':
            iso_path = input("Enter the path to the ISO file: ")
            usb_drive = input("Enter the drive letter or device path of the USB drive: ")
            flash_iso_and_boot(iso_path, usb_drive)
        elif choice == '2':
            usb_drive = input("Enter the drive letter or device path of the USB drive: ")
            verify_bootability(usb_drive)
        elif choice == '3':
            find_usb_drives()
        elif choice == '4':
            print("Exiting DrivePy. Goodbye!")
            break
        else:
            print("Invalid choice. Please enter a valid option.")

if __name__ == "__main__":
    main()

Additional Notes

  • Ensure you have necessary permissions to perform operations like flashing ISO and making bootable.
  • The ISO file must be bootable if you intend to make the USB drive bootable.
  • For Windows, you may need to run the script with administrator privileges for some operations.
  • For macOS, some operations may require sudo privileges.

Thanks

Thank you for using DrivePy!

License

This project is licensed under the MIT License - see the LICENSE file for details.

Release files for drivepy 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for drivepy 1.0.3
File Size Uploaded
drivepy-1.0.3.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for drivepy 1.0.3
File Interpreter ABI Platform
drivepy-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 9.6 kB

Release files / drivepy-1.0.3.tar.gz

Download URL drivepy-1.0.3.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4c2c6c6d5d95a7a354c1534844c9d7f22f260ba2673311b2b1765ab20939a6f0
BLAKE2b-256 checksum
How to use checksums
af218a71bfe544fcb162ab2f81285e7a518fc604ce71eaed06ca2c30f15dc578
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.2

Release files / drivepy-1.0.3-py3-none-any.whl

Download URL drivepy-1.0.3-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e0a80101b49abeb23c4ddeb57cb220d141ca2b8f8a3fa2152442d91c6857626e
BLAKE2b-256 checksum
How to use checksums
c0dd70e64393e8321750428530cd600588bd8539a9cb651c18bc5d07b4d9c9c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.2

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page