src/build/fuchsia/device_target.py
def __Discover(self):
    """Queries mDNS for the IP address of a booted Fuchsia instance whose name
    matches |_node_name| on the local area network. If |_node_name| isn't
    specified, and there is only one device on the network, then returns the
    IP address of that advice.

    Sets |_host_name| and returns True if the device was found,
    or waits up to |timeout| seconds and returns False if the device couldn't
    be found."""

    dev_finder_path = GetHostToolPathFromPlatform('device-finder')

    if self._node_name:
      command = [dev_finder_path, 'resolve',
                 '-device-limit', '1',  # Exit early as soon as a host is found.
                 self._node_name]
    else:
      command = [
          dev_finder_path, 'list', '-full', '-timeout',
          "%ds" % _LIST_DEVICES_TIMEOUT_SECS
      ]

    proc = subprocess.Popen(command,
                            stdout=subprocess.PIPE,
                            stderr=open(os.devnull, 'w'))

    output = set(proc.communicate()[0].strip().split('\n'))

    if proc.returncode != 0:
      return False

    if self._node_name:
      # Handle the result of "device-finder resolve".
      self._host = output.pop().strip()

    else:
      name_host_pairs = [x.strip().split(' ') for x in output]

      # Handle the output of "device-finder list".
      if len(name_host_pairs) > 1:
        print('More than one device was discovered on the network.')
        print('Use --node-name <name> to specify the device to use.')
        print('\nList of devices:')
        for pair in name_host_pairs:
          print('  ' + pair[1])
        print()
        raise Exception('Ambiguous target device specification.')

      assert len(name_host_pairs) == 1
      self._host, self._node_name = name_host_pairs[0]

    logging.info('Found device "%s" at address %s.' % (self._node_name,
                                                       self._host))

    return True
Queries mDNS for the IP address of a booted Fuchsia instance whose name
    matches |_node_name| on the local area network. If |_node_name| isn't
    specified, and there is only one device on the network, then returns the
    IP address of that advice.

    Sets |_host_name| and returns True if the device was found,
    or waits up to |timeout| seconds and returns False if the device couldn't
    be found.
Queries mDNS for the IP address of a booted Fuchsia instance whose name
matches |_node_name| on the local area network. If |_node_name| isn't
specified, and there is only one device on the network, then returns the
IP address of that advice.

Sets |_host_name| and returns True if the device was found,
or waits up to |timeout| seconds and returns False if the device couldn't
be found.
Queries mDNS for the IP address of a booted Fuchsia instance whose name matches |_node_name| on the local area network . If |_node_name| isn ' t specified and there is only one device on the network then returns the IP address of that advice . Sets |_host_name| and returns True if the device was found or waits up to |timeout| seconds and returns False if the device couldn ' t be found .
def __Discover(self):
    dev_finder_path = GetHostToolPathFromPlatform('device-finder')
    if self._node_name:
      command = [dev_finder_path, 'resolve',
                 '-device-limit', '1',  
                 self._node_name]
    else:
      command = [
          dev_finder_path, 'list', '-full', '-timeout',
          "%ds" % _LIST_DEVICES_TIMEOUT_SECS
      ]
    proc = subprocess.Popen(command,
                            stdout=subprocess.PIPE,
                            stderr=open(os.devnull, 'w'))
    output = set(proc.communicate()[0].strip().split('\n'))
    if proc.returncode != 0:
      return False
    if self._node_name:
      self._host = output.pop().strip()
    else:
      name_host_pairs = [x.strip().split(' ') for x in output]
      if len(name_host_pairs) > 1:
        print('More than one device was discovered on the network.')
        print('Use --node-name <name> to specify the device to use.')
        print('\nList of devices:')
        for pair in name_host_pairs:
          print('  ' + pair[1])
        print()
        raise Exception('Ambiguous target device specification.')
      assert len(name_host_pairs) == 1
      self._host, self._node_name = name_host_pairs[0]
    logging.info('Found device "%s" at address %s.' % (self._node_name,
                                                       self._host))
    return True
def __Discover ( self ) : dev_finder_path = GetHostToolPathFromPlatform ( 'device-finder' ) if self . _node_name : command = [ dev_finder_path , 'resolve' , '-device-limit' , '1' , self . _node_name ] else : command = [ dev_finder_path , 'list' , '-full' , '-timeout' , "%ds" % _LIST_DEVICES_TIMEOUT_SECS ] proc = subprocess . Popen ( command , stdout = subprocess . PIPE , stderr = open ( os . devnull , 'w' ) ) output = set ( proc . communicate ( ) [ 0 ] . strip ( ) . split ( '\n' ) ) if proc . returncode != 0 : return False if self . _node_name : self . _host = output . pop ( ) . strip ( ) else : name_host_pairs = [ x . strip ( ) . split ( ' ' ) for x in output ] if len ( name_host_pairs ) > 1 : print ( 'More than one device was discovered on the network.' ) print ( 'Use --node-name <name> to specify the device to use.' ) print ( '\nList of devices:' ) for pair in name_host_pairs : print ( '  ' + pair [ 1 ] ) print ( ) raise Exception ( 'Ambiguous target device specification.' ) assert len ( name_host_pairs ) == 1 self . _host , self . _node_name = name_host_pairs [ 0 ] logging . info ( 'Found device "%s" at address %s.' % ( self . _node_name , self . _host ) ) return True
Queries mDNS for the IP address of a booted Fuchsia instance whose name
matches |_node_name| on the local area network.
Queries mDNS for the IP address of a booted Fuchsia instance whose name matches |_node_name| on the local area network .
"""Queries mDNS for the IP address of a booted Fuchsia instance whose name
    matches |_node_name| on the local area network. If |_node_name| isn't
    specified, and there is only one device on the network, then returns the
    IP address of that advice.

    Sets |_host_name| and returns True if the device was found,
    or waits up to |timeout| seconds and returns False if the device couldn't
    be found.""" # Exit early as soon as a host is found. # Handle the result of "device-finder resolve". # Handle the output of "device-finder list".
self