code: def _parse_dyn_inventory(self, script):
          
          self.log.debug("Reading dynamic inventory {0}".format(script))
          try:
              proc = subprocess.Popen([script, '--list'],
                                      stdout=subprocess.PIPE,
                                      stderr=subprocess.PIPE,
                                      close_fds=True)
              stdout, stderr = proc.communicate(input)
              if proc.returncode != 0:
                  sys.stderr.write("Dynamic inventory script '{0}' returned "
                                   "exitcode {1}\n".format(script,
                                                           proc.returncode))
                  for line in stderr:
                      sys.stderr.write(line)
  
              dyninv_parser = parser.DynInvParser(stdout.decode('utf8'))
              for hostname, key_values in dyninv_parser.hosts.items():
                  self.update_host(hostname, key_values)
          except OSError as err:
              sys.stderr.write("Exception while executing dynamic inventory script '{0}':\n\n".format(script))
              sys.stderr.write(str(err) + '\n')
docs: Execute a dynamic inventory script and parse the results.