def GetClientConfig(self, context, validate=True):
    """Generates the client config file for inclusion in deployable binaries."""
    with utils.TempDirectory() as tmp_dir:
      # Make sure we write the file in yaml format.
      filename = os.path.join(
          tmp_dir, config_lib.CONFIG.Get(
              "ClientBuilder.config_filename", context=context))

      new_config = config_lib.CONFIG.MakeNewConfig()
      new_config.Initialize(reset=True, data="")
      new_config.SetWriteBack(filename)

      # Only copy certain sections to the client. We enumerate all
      # defined options and then resolve those from the config in the
      # client's context. The result is the raw option as if the
      # client read our config file.
      for descriptor in sorted(config_lib.CONFIG.type_infos,
                               key=lambda x: x.name):
        if descriptor.name in self.SKIP_OPTION_LIST:
          continue

        if descriptor.section in self.CONFIG_SECTIONS:
          value = config_lib.CONFIG.GetRaw(
              descriptor.name, context=context,
              default=None)

          if value is not None:
            logging.debug("Copying config option to client: %s",
                          descriptor.name)

            new_config.SetRaw(descriptor.name, value)

      new_config.Set("Client.deploy_time",
                     str(rdfvalue.RDFDatetime().Now()))

      # Update the plugins list in the configuration file. Note that by
      # stripping away directory information, the client will load these from
      # its own install path.
      plugins = []
      for plugin in config_lib.CONFIG["Client.plugins"]:
        plugins.append(os.path.basename(plugin))

      new_config.SetRaw("Client.plugins", plugins)
      new_config.Write()

      if validate:
        self.ValidateEndConfig(new_config)

      return open(filename, "rb").read()
dataset/ETHPy150Open google/grr/grr/lib/build.py/ClientDeployer.GetClientConfig/original