Add unexpected error handler
This commit is contained in:
parent
f4c68e6bbb
commit
ac1f25ccbc
|
@ -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? |
|
||||
| 254 | Is it nabu? |
|
||||
|
|
|
@ -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 != "",
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
Reference in a new issue