parameters: (self)
return_statement: return True
docstring: 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.
docstring_summary: 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.
docstring_tokens: 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 .
function: 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')
  
      with open(os.devnull, 'w') as devnull:
        if self._node_name:
          command = [
              dev_finder_path,
              'resolve',
              '-device-limit',
              '1',  # Exit early as soon as a host is found.
              self._node_name
          ]
          proc = subprocess.Popen(command,
                                  stdout=subprocess.PIPE,
                                  stderr=devnull,
                                  text=True)
        else:
          proc = self.RunFFXCommand(['target', 'list', '-f', 'simple'],
                                    stdout=subprocess.PIPE,
                                    stderr=devnull,
                                    text=True)
  
      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]
  
        if len(name_host_pairs) > 1:
          raise Exception('More than one device was discovered on the network. '
                          'Use --node-name <name> to specify the device to use.'
                          'List of devices: {}'.format(output))
        assert len(name_host_pairs) == 1
        # Check if device has both address and name.
        if len(name_host_pairs[0]) < 2:
          return False
        self._host, self._node_name = name_host_pairs[0]
  
      logging.info('Found device "%s" at address %s.' % (self._node_name,
                                                         self._host))
  
      return True
function_tokens: def _Discover ( self ) : dev_finder_path = GetHostToolPathFromPlatform ( 'device-finder' ) with open ( os . devnull , 'w' ) as devnull : if self . _node_name : command = [ dev_finder_path , 'resolve' , '-device-limit' , '1' , # Exit early as soon as a host is found. self . _node_name ] proc = subprocess . Popen ( command , stdout = subprocess . PIPE , stderr = devnull , text = True ) else : proc = self . RunFFXCommand ( [ 'target' , 'list' , '-f' , 'simple' ] , stdout = subprocess . PIPE , stderr = devnull , text = True ) 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 ] if len ( name_host_pairs ) > 1 : raise Exception ( 'More than one device was discovered on the network. ' 'Use --node-name <name> to specify the device to use.' 'List of devices: {}' . format ( output ) ) assert len ( name_host_pairs ) == 1 # Check if device has both address and name. if len ( name_host_pairs [ 0 ] ) < 2 : return False self . _host , self . _node_name = name_host_pairs [ 0 ] logging . info ( 'Found device "%s" at address %s.' % ( self . _node_name , self . _host ) ) return True