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
|
||||
|
||||
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):
|
||||
try:
|
||||
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()
|
||||
with Mobilebackup2Service(lockdown_client) as mb:
|
||||
mb.restore(backup_dir, system=True, reboot=False, copy=False, source=".")
|
||||
# reboot the device
|
||||
reboot_device(reboot, lockdown_client)
|
||||
except PyMobileDevice3Exception as e:
|
||||
if "Find My" in str(e):
|
||||
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):
|
||||
raise e
|
||||
else:
|
||||
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!")
|
||||
reboot_device(reboot, lockdown_client)
|
||||
Reference in New Issue
Block a user