A tool for managing USB drives and flashing ISOs
Project description
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
drivepy-1.0.3.tar.gz
(4.7 kB
view details)
Built Distribution
File details
Details for the file drivepy-1.0.3.tar.gz
.
File metadata
- Download URL: drivepy-1.0.3.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c2c6c6d5d95a7a354c1534844c9d7f22f260ba2673311b2b1765ab20939a6f0 |
|
MD5 | 1c28e1d93d0ecb84285ba922a58b8a1f |
|
BLAKE2b-256 | af218a71bfe544fcb162ab2f81285e7a518fc604ce71eaed06ca2c30f15dc578 |
File details
Details for the file drivepy-1.0.3-py3-none-any.whl
.
File metadata
- Download URL: drivepy-1.0.3-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0a80101b49abeb23c4ddeb57cb220d141ca2b8f8a3fa2152442d91c6857626e |
|
MD5 | 815975bdff48606fed6a968de3eb15d6 |
|
BLAKE2b-256 | c0dd70e64393e8321750428530cd600588bd8539a9cb651c18bc5d07b4d9c9c5 |