@LocalContext
def wait_for_device(kick=False):
 with log.waitfor('Waiting for device to come online') as w:
  with AdbClient() as c:
   if kick:
    try:
     c.reconnect()
    except Exception:
     pass
   serial = ''
   if context.device:
    serial = str(context.device)
  with AdbClient() as c:
   c.wait_for_device(serial)
  for device in devices():
   if (context.device == device):
    return device
   if (not serial):
    break
  else:
   log.error('Could not find any devices')
  with context.local(device=device):
   w.success(('%s (%s %s %s)' % (device, product(), build(), _build_date())))
   return context.device

@ LocalContext def wait_for_device ( kick = False ) : with log . waitfor ( 'Waiting for device to come online' ) as w : with AdbClient ( ) as c : if kick : try : c . reconnect ( ) except Exception : pass serial = '' if context . device : serial = str ( context . device ) with AdbClient ( ) as c : c . wait_for_device ( serial ) for device in devices ( ) : if ( context . device == device ) : return device if ( not serial ) : break else : log . error ( 'Could not find any devices' ) with context . local ( device = device ) : w . success ( ( '%s (%s %s %s)' % ( device , product ( ) , build ( ) , _build_date ( ) ) ) ) return context . device
waits for a device to be connected .