Highlights
✨ Dedicated exceptions for common lockdown errors
lockdownd answers a rejected request with an Error string, and until now three of the most
actionable ones all collapsed into a generic LockdownError, leaving callers to string-match the
message to tell them apart. They now raise their own exception types, so you can recover from each
condition on its own terms:
lockdown Error |
exception | meaning |
|---|---|---|
MCProtected |
MCProtectedError |
a mobile configuration (MDM) policy prohibits the action |
PasscodeRequired |
PasscodeRequiredError |
the device must have a passcode set first |
SessionActive |
SessionActiveError |
a lockdown session is already active (e.g. pairing verified twice) |
All three subclass LockdownError and keep the original error text, device identifier and
product_version, so existing except LockdownError handlers keep working unchanged.
from pymobiledevice3.exceptions import MCProtectedError, PasscodeRequiredError
from pymobiledevice3.lockdown import create_using_usbmux
lockdown = await create_using_usbmux()
try:
await lockdown.set_value(True, "com.apple.mobile.wireless_lockdown", "EnableWifiConnections")
except MCProtectedError:
print("blocked by an MDM profile")
except PasscodeRequiredError:
print("set a device passcode first")Resolves #708. Thanks @NspxMiguel for the contribution!
What's Changed
- f6fab97 lockdown: Map common errors to dedicated exceptions (#1948) (@NspxMiguel)
- 9e38110 webinspector: Test a missing WIRAutomationAvailabilityKey reads as Unknown (#1947) (@doronz88)
New Contributors
- @NspxMiguel made their first contribution in #1948
Full Changelog: v11.12.4...v11.12.5