diff --git a/README.md b/README.md index 78f5a79..450711c 100644 --- a/README.md +++ b/README.md @@ -17,5 +17,6 @@ | 176 | Failed to patch boot image | | 177 | Failed to boot recovery | | 178 | Platform is not supported | +| 179 | Unexpected error | | 253 | User cancel | -| 254 | Is it nabu? | \ No newline at end of file +| 254 | Is it nabu? | diff --git a/lon_deployer/fastboot.py b/lon_deployer/fastboot.py index 607b2c4..ed8ed79 100644 --- a/lon_deployer/fastboot.py +++ b/lon_deployer/fastboot.py @@ -5,7 +5,7 @@ from . import files, exceptions from .utils import logger, console -def _fastboot_run(command: [str], serial: str = None) -> str: +def _fastboot_run(command: list[str], serial: str | None = None) -> str: try: cmd = ["fastboot"] if not serial: @@ -19,13 +19,13 @@ def _fastboot_run(command: [str], serial: str = None) -> str: console.log("Fastboot binary not found") console.log("Exiting") exit(1) - except subprocess.CalledProcessError: + except subprocess.TimeoutExpired: raise exceptions.DeviceNotFound("Timed out") else: return fb_out.decode() -def list_devices() -> [str]: +def list_devices() -> list[str]: return list( filter( lambda x: x != "", diff --git a/lon_deployer/main.py b/lon_deployer/main.py index 4a0cec5..0e7b12b 100644 --- a/lon_deployer/main.py +++ b/lon_deployer/main.py @@ -256,6 +256,10 @@ def main() -> int: console.log("Reflash your rom and try again") fastboot.reboot(serial) return 177 + except subprocess.CalledProcessError as e: + console.log("Fastboot error. Please contact developer") + console.log("Executed command", e.cmd) + return 179 with console.status("[cyan]Waiting for device", spinner="line", spinner_style="white"): try: adb.wait_for(serial, state="recovery") @@ -296,6 +300,10 @@ def main() -> int: console.log("Reflash your rom and try again") fastboot.reboot(serial) return 177 + except subprocess.CalledProcessError as e: + console.log("Fastboot error. Please contact developer") + console.log("Executed command", e.cmd) + return 179 with console.status("[cyan]Waiting for device", spinner="line", spinner_style="white"): try: diff --git a/lon_deployer/utils.py b/lon_deployer/utils.py index 60ce955..1db7ca5 100644 --- a/lon_deployer/utils.py +++ b/lon_deployer/utils.py @@ -91,8 +91,7 @@ def repartition(serial: str, size: int, percents=False) -> None: f"parted -s /dev/block/sda rm 31", f"parted -s /dev/block/sda mkpart userdata ext4 10.9GB {userdata_end}GB", f"parted -s /dev/block/sda mkpart linux ext4 {userdata_end}GB {linux_end}GB", - f"parted -s /dev/block/sda mkpart esp fat32 {linux_end}GB {maxsize}GB", - f"parted -s /dev/block/sda set 33 esp on" + f"parted -s /dev/block/sda mkpart esp fat32 {linux_end}GB {maxsize}GB" ] for cmd in cmds: device.shell(cmd)