(
            self, analyzer_names, analyzer_kwargs=None, ignore_previous=False)
return analyzer_results
Run an analyzer on a timeline.

        Args:
            analyzer_names: a list of analyzer class names to run against the
                timeline.
            analyzer_kwargs: optional dict with parameters for the analyzer.
                This is optional and just for those analyzers that can accept
                further parameters. It is expected that this is a dict with
                the key value being the analyzer name, and the value being
                another key/value dict with the parameters for that analyzer.
            ignore_previous (bool): an optional bool, if set to True then
                analyzer is run irrelevant on whether it has been previously
                been run.

        Raises:
            error.UnableToRunAnalyzer: if not able to run the analyzer.

        Returns:
            If the analyzer runs successfully return back a list of
            AnalyzerResult objects.
Run an analyzer on a timeline.
Run an analyzer on a timeline .
def run_analyzers(
            self, analyzer_names, analyzer_kwargs=None, ignore_previous=False):
        """Run an analyzer on a timeline.

        Args:
            analyzer_names: a list of analyzer class names to run against the
                timeline.
            analyzer_kwargs: optional dict with parameters for the analyzer.
                This is optional and just for those analyzers that can accept
                further parameters. It is expected that this is a dict with
                the key value being the analyzer name, and the value being
                another key/value dict with the parameters for that analyzer.
            ignore_previous (bool): an optional bool, if set to True then
                analyzer is run irrelevant on whether it has been previously
                been run.

        Raises:
            error.UnableToRunAnalyzer: if not able to run the analyzer.

        Returns:
            If the analyzer runs successfully return back a list of
            AnalyzerResult objects.
        """
        if self.is_archived():
            raise error.UnableToRunAnalyzer(
                'Unable to run an analyzer on an archived timeline.')

        resource_url = '{0:s}/sketches/{1:d}/analyzer/'.format(
            self.api.api_root, self._sketch_id)

        if not ignore_previous:
            all_names = {x.lower() for x in analyzer_names}
            done_names = set()

            response = self.api.fetch_resource_data(
                f'sketches/{self._sketch_id}/timelines/{self.id}/analysis/')
            analyzer_data = response.get('objects', [[]])

            if analyzer_data:
                for result in analyzer_data[0]:
                    result_analyzer = result.get('analyzer_name', 'N/A')
                    done_names.add(result_analyzer.lower())

            analyzer_names = list(all_names.difference(done_names))
            for name in all_names.intersection(done_names):
                logger.error(
                    'Analyzer {0:s} has already been run on the timeline, '
                    'use "ignore_previous=True" to overwrite'.format(
                        name))

            if not analyzer_names:
                return None

        data = {
            'timeline_ids': [self.id],
            'analyzer_names': analyzer_names,
            'analyzer_kwargs': analyzer_kwargs,
        }
        response = self.api.session.post(resource_url, json=data)

        if not error.check_return_status(response, logger):
            raise error.UnableToRunAnalyzer('[{0:d}] {1!s} {2!s}'.format(
                response.status_code, response.reason, response.text))

        data = error.get_response_json(response, logger)
        objects = data.get('objects', [])
        if not objects:
            raise error.UnableToRunAnalyzer(
                'No session data returned back, analyzer may have run but '
                'unable to verify, please verify manually.')

        analyzer_results = []
        for session_dict in objects[0]:
            for analysis_dict in session_dict.get('analyses', []):
                session_id = analysis_dict.get('analysissession_id')
                if not session_id:
                    continue
                analyzer_result = analyzer.AnalyzerResult(
                    timeline_id=self.id, session_id=session_id,
                    sketch_id=self._sketch_id, api=self.api)
                analyzer_results.append(analyzer_result)

        if not analyzer_results:
            raise error.UnableToRunAnalyzer(
                'Analyzer may have run, but there are no analyzer results to '
                'verify that it has. Please verify manually.')

        return analyzer_results
def run_analyzers ( self , analyzer_names , analyzer_kwargs = None , ignore_previous = False ) : if self . is_archived ( ) : raise error . UnableToRunAnalyzer ( 'Unable to run an analyzer on an archived timeline.' ) resource_url = '{0:s}/sketches/{1:d}/analyzer/' . format ( self . api . api_root , self . _sketch_id ) if not ignore_previous : all_names = { x . lower ( ) for x in analyzer_names } done_names = set ( ) response = self . api . fetch_resource_data ( f'sketches/{self._sketch_id}/timelines/{self.id}/analysis/' ) analyzer_data = response . get ( 'objects' , [ [ ] ] ) if analyzer_data : for result in analyzer_data [ 0 ] : result_analyzer = result . get ( 'analyzer_name' , 'N/A' ) done_names . add ( result_analyzer . lower ( ) ) analyzer_names = list ( all_names . difference ( done_names ) ) for name in all_names . intersection ( done_names ) : logger . error ( 'Analyzer {0:s} has already been run on the timeline, ' 'use "ignore_previous=True" to overwrite' . format ( name ) ) if not analyzer_names : return None data = { 'timeline_ids' : [ self . id ] , 'analyzer_names' : analyzer_names , 'analyzer_kwargs' : analyzer_kwargs , } response = self . api . session . post ( resource_url , json = data ) if not error . check_return_status ( response , logger ) : raise error . UnableToRunAnalyzer ( '[{0:d}] {1!s} {2!s}' . format ( response . status_code , response . reason , response . text ) ) data = error . get_response_json ( response , logger ) objects = data . get ( 'objects' , [ ] ) if not objects : raise error . UnableToRunAnalyzer ( 'No session data returned back, analyzer may have run but ' 'unable to verify, please verify manually.' ) analyzer_results = [ ] for session_dict in objects [ 0 ] : for analysis_dict in session_dict . get ( 'analyses' , [ ] ) : session_id = analysis_dict . get ( 'analysissession_id' ) if not session_id : continue analyzer_result = analyzer . AnalyzerResult ( timeline_id = self . id , session_id = session_id , sketch_id = self . _sketch_id , api = self . api ) analyzer_results . append ( analyzer_result ) if not analyzer_results : raise error . UnableToRunAnalyzer ( 'Analyzer may have run, but there are no analyzer results to ' 'verify that it has. Please verify manually.' ) return analyzer_results