Skip to content

Commit

Permalink
pairing_records: add get_usbmux_pairing_record()
Browse files Browse the repository at this point in the history
  • Loading branch information
AnNEDoMini authored Oct 19, 2024
1 parent fb9093c commit 6b8e691
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions pymobiledevice3/pair_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ def generate_host_id(hostname: str = None) -> str:
return str(host_id).upper()


def get_usbmux_pairing_record(identifier: str, usbmux_address: Optional[str] = None):
with suppress(NotPairedError, MuxException):
with usbmux.create_mux(usbmux_address=usbmux_address) as mux:
if isinstance(mux, PlistMuxConnection):
pair_record = mux.get_pair_record(identifier)
if pair_record is not None:
return pair_record
return None


def get_itunes_pairing_record(identifier: str) -> Optional[dict]:
filename = OSUTILS.pair_record_path / f'{identifier}.plist'
try:
Expand Down Expand Up @@ -53,12 +63,9 @@ def get_preferred_pair_record(identifier: str, pairing_records_cache_folder: Pat
"""

# usbmuxd
with suppress(NotPairedError, MuxException):
with usbmux.create_mux(usbmux_address=usbmux_address) as mux:
if isinstance(mux, PlistMuxConnection):
pair_record = mux.get_pair_record(identifier)
if pair_record is not None:
return pair_record
pair_record = get_usbmux_pairing_record(identifier=identifier, usbmux_address=usbmux_address)
if pair_record is not None:
return pair_record

# iTunes
pair_record = get_itunes_pairing_record(identifier)
Expand Down

0 comments on commit 6b8e691

Please sign in to comment.