@flow.StateHandler()
  def Start(self):
    """Initializes this hunt from arguments."""

    self.state.context.Register("results_metadata_urn",
                                self.urn.Add("ResultsMetadata"))
    self.state.context.Register("results_collection_urn",
                                self.urn.Add("Results"))
    self.state.context.Register("output_plugins_base_urn",
                                self.urn.Add("Results"))

    with aff4.FACTORY.Create(
        self.state.context.results_metadata_urn, "HuntResultsMetadata",
        mode="rw", token=self.token) as results_metadata:

      state = rdf_flows.FlowState()
      try:
        plugins_descriptors = self.state.args.output_plugins
      except __HOLE__:
        plugins_descriptors = []

      for index, plugin_descriptor in enumerate(plugins_descriptors):
        output_base_urn = self.state.context.output_plugins_base_urn.Add(
            plugin_descriptor.plugin_name)

        plugin_class = plugin_descriptor.GetPluginClass()
        plugin_obj = plugin_class(self.state.context.results_collection_urn,
                                  output_base_urn=output_base_urn,
                                  args=plugin_descriptor.plugin_args,
                                  token=self.token)

        state.Register("%s_%d" % (plugin_descriptor.plugin_name, index),
                       (plugin_descriptor, plugin_obj.state))

      results_metadata.Set(results_metadata.Schema.OUTPUT_PLUGINS(state))

    # Create the collection for results.
    with aff4.FACTORY.Create(self.state.context.results_collection_urn,
                             "HuntResultCollection",
                             mode="w",
                             token=self.token):
      pass

    # Create the collection for logs.
    with aff4.FACTORY.Create(self.logs_collection_urn,
                             flow_runner.FlowLogCollection.__name__,
                             mode="w",
                             token=self.token):
      pass

    # Create the collections for urns.
    for urn in [self.all_clients_collection_urn,
                self.completed_clients_collection_urn,
                self.clients_with_results_collection_urn]:
      with aff4.FACTORY.Create(urn, "UrnCollection",
                               mode="w", token=self.token):
        pass

    # Create the collection for errors.
    with aff4.FACTORY.Create(self.clients_errors_collection_urn,
                             "HuntErrorCollection",
                             mode="w",
                             token=self.token):
      pass

    # Create the collections for PluginStatus messages.
    for urn in [self.output_plugins_status_collection_urn,
                self.output_plugins_errors_collection_urn]:
      with aff4.FACTORY.Create(urn, "PluginStatusCollection",
                               mode="w", token=self.token):
        pass

    if not self.state.context.args.description:
      self.SetDescription()
dataset/ETHPy150Open google/grr/grr/lib/hunts/implementation.py/GRRHunt.Start