MCPcopy Index your code
hub / github.com/python/cpython / find_device

Function find_device

Android/android.py:484–498  ·  view source on GitHub ↗
(context, initial_devices)

Source from the content-addressed store, hash-verified

482
483
484async def find_device(context, initial_devices):
485 if context.managed:
486 print("Waiting for managed device - this may take several minutes")
487 while True:
488 new_devices = set(await list_devices()).difference(initial_devices)
489 if len(new_devices) == 0:
490 await asyncio.sleep(1)
491 elif len(new_devices) == 1:
492 serial = new_devices.pop()
493 print(f"Serial: {serial}")
494 return serial
495 else:
496 exit(f"Found more than one new device: {new_devices}")
497 else:
498 return context.connected
499
500
501# An older version of this script in #121595 filtered the logs by UID instead.

Callers 1

logcat_taskFunction · 0.85

Calls 6

setFunction · 0.85
list_devicesFunction · 0.85
differenceMethod · 0.80
exitFunction · 0.70
sleepMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…