mirror of
https://github.com/leminlimez/Nugget.git
synced 2025-04-08 04:23:05 +08:00
fix reboot when there is no crash
This commit is contained in:
@@ -9,6 +9,13 @@ from pymobiledevice3.lockdown import LockdownClient
|
|||||||
|
|
||||||
from . import backup
|
from . import backup
|
||||||
|
|
||||||
|
def reboot_device(reboot: bool = False, lockdown_client: LockdownClient = None):
|
||||||
|
if reboot and lockdown_client != None:
|
||||||
|
print("Success! Rebooting your device...")
|
||||||
|
with DiagnosticsService(lockdown_client) as diagnostics_service:
|
||||||
|
diagnostics_service.restart()
|
||||||
|
print("Remember to turn Find My back on!")
|
||||||
|
|
||||||
def perform_restore(backup: backup.Backup, reboot: bool = False, lockdown_client: LockdownClient = None):
|
def perform_restore(backup: backup.Backup, reboot: bool = False, lockdown_client: LockdownClient = None):
|
||||||
try:
|
try:
|
||||||
with TemporaryDirectory() as backup_dir:
|
with TemporaryDirectory() as backup_dir:
|
||||||
@@ -18,6 +25,8 @@ def perform_restore(backup: backup.Backup, reboot: bool = False, lockdown_client
|
|||||||
lockdown_client = create_using_usbmux()
|
lockdown_client = create_using_usbmux()
|
||||||
with Mobilebackup2Service(lockdown_client) as mb:
|
with Mobilebackup2Service(lockdown_client) as mb:
|
||||||
mb.restore(backup_dir, system=True, reboot=False, copy=False, source=".")
|
mb.restore(backup_dir, system=True, reboot=False, copy=False, source=".")
|
||||||
|
# reboot the device
|
||||||
|
reboot_device(reboot, lockdown_client)
|
||||||
except PyMobileDevice3Exception as e:
|
except PyMobileDevice3Exception as e:
|
||||||
if "Find My" in str(e):
|
if "Find My" in str(e):
|
||||||
print("Find My must be disabled in order to use this tool.")
|
print("Find My must be disabled in order to use this tool.")
|
||||||
@@ -26,8 +35,4 @@ def perform_restore(backup: backup.Backup, reboot: bool = False, lockdown_client
|
|||||||
elif "crash_on_purpose" not in str(e):
|
elif "crash_on_purpose" not in str(e):
|
||||||
raise e
|
raise e
|
||||||
else:
|
else:
|
||||||
if reboot and lockdown_client != None:
|
reboot_device(reboot, lockdown_client)
|
||||||
print("Success! Rebooting your device...")
|
|
||||||
with DiagnosticsService(lockdown_client) as diagnostics_service:
|
|
||||||
diagnostics_service.restart()
|
|
||||||
print("Remember to turn Find My back on!")
|
|
||||||
Reference in New Issue
Block a user