Adds an analysis report.

    Args:
      analysis_report (AnalysisReport): analysis report.

    Raises:
      IOError: when the storage writer is closed.
      OSError: when the storage writer is closed.
350613
def AddAnalysisReport(self, analysis_report):
    
    self._RaiseIfNotWritable()

    self._storage_file.AddAnalysisReport(analysis_report)

    report_identifier = analysis_report.plugin_name
    self._session.analysis_reports_counter['total'] += 1
    self._session.analysis_reports_counter[report_identifier] += 1
    self.number_of_analysis_reports += 1
697233
def _keep_analyses( analyses, keep_forms, target_forms ):
    '''  '''
    to_delete = []
    for aid, analysis in enumerate(analyses):
        delete = False
        for target in target_forms:
            if (target == analysis[FORM] and not analysis[FORM] in keep_forms):
               delete = True
        if delete:
            to_delete.append( aid )
    if to_delete:
       to_delete.reverse()
       for aid in to_delete:
           del analyses[aid]
365713
def AnalyzeEvents(self):
    
    session = engine.BaseEngine.CreateSession(
        command_line_arguments=self._command_line_arguments,
        preferred_encoding=self.preferred_encoding)

    storage_reader = storage_factory.StorageFactory.CreateStorageReaderForFile(
        self._storage_file_path)
    if not storage_reader:
      logger.error('Format of storage file: {0:s} not supported'.format(
          self._storage_file_path))
      return

    self._number_of_analysis_reports = (
        storage_reader.GetNumberOfAnalysisReports())
    storage_reader.Close()

    configuration = self._CreateProcessingConfiguration(
        self._knowledge_base)

    counter = collections.Counter()
    if self._output_format != 'null':
      self._status_view.SetMode(self._status_view_mode)
      self._status_view.SetStorageFileInformation(self._storage_file_path)

      status_update_callback = (
          self._status_view.GetAnalysisStatusUpdateCallback())

      storage_reader = (
          storage_factory.StorageFactory.CreateStorageReaderForFile(
              self._storage_file_path))

      # TODO: add single processing support.
      analysis_engine = psort.PsortMultiProcessEngine(
          use_zeromq=self._use_zeromq)

      analysis_engine.ExportEvents(
          self._knowledge_base, storage_reader, self._output_module,
          configuration, deduplicate_events=self._deduplicate_events,
          status_update_callback=status_update_callback,
          time_slice=self._time_slice, use_time_slicer=self._use_time_slicer)

    for item, value in iter(session.analysis_reports_counter.items()):
      counter[item] = value

    if self._quiet_mode:
      return

    self._output_writer.Write('Processing completed.\n')

    table_view = views.ViewsFactory.GetTableView(
        self._views_format_type, title='Counter')
    for element, count in counter.most_common():
      if not element:
        element = 'N/A'
      table_view.AddRow([element, count])
    table_view.Write(self._output_writer)

    storage_reader = storage_factory.StorageFactory.CreateStorageReaderForFile(
        self._storage_file_path)
    self._PrintAnalysisReportsDetails(
        storage_reader, self._number_of_analysis_reports)

    self._output_writer.Write('Storage file is {0:s}\n'.format(
        self._storage_file_path))
1198011
def delete_report(report):
    
    for path in glob.glob(os.path.join(_get_reports_path(), report)):
        shutil.rmtree(path)
1143143
def place_analysis_summary_report(feature, parent):
    
    _ = feature, parent  # NOQA
    analysis_dir = get_analysis_dir(exposure_place['key'])
    if analysis_dir:
        return get_impact_report_as_string(analysis_dir)
    return None
360514
def _ContinueReportCompilation(self):
    
    analyzer_alive = self._analyzer.is_alive()
    hash_queue_has_tasks = self.hash_queue.unfinished_tasks > 0
    analysis_queue = not self.hash_analysis_queue.empty()

    # pylint: disable=consider-using-ternary
    return (analyzer_alive and hash_queue_has_tasks) or analysis_queue
63982
def write_report(self, template):
        
        with open(self.fn, 'w') as f:
            f.write(template)
1034870
public static void dumpAnalysisToFile(String outputDirName,
                                          String baseFileName,
                                          PartitionBalance partitionBalance) {
        if(outputDirName != null) {
            File outputDir = new File(outputDirName);
            if(!outputDir.exists()) {
                Utils.mkdirs(outputDir);
            }

            try {
                FileUtils.writeStringToFile(new File(outputDirName, baseFileName + ".analysis"),
                                            partitionBalance.toString());
            } catch(IOException e) {
                logger.error("IOException during dumpAnalysisToFile: " + e);
            }
        }
    }
175058
def add(self, si):
        '''

        '''
        if self.o_chunk is None:
            if os.path.exists(self.t_path):
                os.remove(self.t_path)
            self.o_chunk = streamcorpus.Chunk(self.t_path, mode='wb')
        self.o_chunk.add(si)
        logger.debug('added %d-th item to chunk', len(self.o_chunk))
        if len(self.o_chunk) == self.chunk_max:
            self.close()
1028159
def runner(self):
        
        if os.path.isfile(self.report):
            self.report_parse()
        else:
            logging.info('Starting {} analysis pipeline'.format(self.analysistype))
            # Create the objects to be used in the analyses (if required)
            general = None
            for sample in self.runmetadata.samples:
                general = getattr(sample, 'general')
            if general is None:
                # Create the objects to be used in the analyses
                objects = Objectprep(self)
                objects.objectprep()
                self.runmetadata = objects.samples
            # Run the analyses
            MLSTmap(self, self.analysistype, self.cutoff)
            # Create the reports
            self.reporter()
            # Print the metadata to a .json file
            MetadataPrinter(self)
483897
def write_report(self, session, filename):
        
        if not self.__report:
            session.write_line("No report to write down")
            return

        try:
            with open(filename, "w+") as out_file:
                out_file.write(self.to_json(self.__report))
        except IOError as ex:
            session.write_line("Error writing to file: {0}", ex)
1053569
def create(cls, sample, analysis_system):
        
        return cls._create(sample=sample.url, analysis_system=analysis_system.url)
1144678
def make_report(self, outcome):
        
        failures = self.getreports('failed')
        if not failures:
            return
        for rep in failures:
            # Check if this is a notebook node
            msg = self._getfailureheadline(rep)
            lines = rep.longrepr.splitlines()
            if len(lines) > 1:
                self.section(msg, lines[1])
            self._outrep_summary(rep)
        tmpdir = tempfile.mkdtemp()
        try:
            ref_file = os.path.join(tmpdir, 'reference.ipynb')
            test_file = os.path.join(tmpdir, 'test_result.ipynb')
            with io.open(ref_file, "w", encoding="utf8") as f:
                nbformat.write(self.nb_ref, f)
            with io.open(test_file, "w", encoding="utf8") as f:
                nbformat.write(self.nb_test, f)
            run_server(
                port=0,     # Run on random port
                cwd=tmpdir,
                closable=True,
                on_port=lambda port: browse(
                    port, ref_file, test_file, None))
        finally:
            shutil.rmtree(tmpdir)
1221206
def add_output(summary_output, long_output, helper):
    
    if summary_output != '':
        helper.add_summary(summary_output)
    helper.add_long_output(long_output)
182201
def add_output_arg(self, out):
        
        self.add_arg(out._dax_repr())
        self._add_output(out)
820702
def analysis_describe(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/describe' % object_id, input_params, always_retry=always_retry, **kwargs)
1355821
def add_to_archive(self, spec):
        '''
        
        '''
        if isinstance(spec, InsightsCommand):
            archive_path = os.path.join(self.cmd_dir, spec.archive_path.lstrip('/'))
        if isinstance(spec, InsightsFile):
            archive_path = self.get_full_archive_path(spec.archive_path.lstrip('/'))
        output = spec.get_output()
        if output:
            write_data_to_file(output, archive_path)