Пример #1
0
    def run(self):
        """ Executes the analysis process, iterating through each of the analysis stages before
            cleaning up and exiting. """

        print('[OUTPUT PATH]: %s' % self.analysisRootPath)
        print(analysisStamp)
        print(tracksStamp)

        self._startTime = TimeUtils.getNowDatetime()

        myRootPath = self.getPath(isDir=True)
        if os.path.exists(myRootPath):
            FileUtils.emptyFolder(myRootPath)
        if not os.path.exists(myRootPath):
            os.makedirs(myRootPath)

        tempPath = self.tempPath
        if os.path.exists(tempPath):
            SystemUtils.remove(tempPath)
        os.makedirs(tempPath)

        if not self.logger.loggingPath:
            self.logger.loggingPath = myRootPath

        try:
            session = self.getAnalysisSession()
            self._preAnalyze()
            for stage in self._stages:
                self._currentStage = stage
                stage.analyze()
            self._currentStage = None
            self._postAnalyze()

            session.commit()
            session.close()
            self._success = True
        except Exception as err:
            session = self.getAnalysisSession()
            session.close()
            msg = [
                '[ERROR]: Failed to execute analysis',
                'STAGE: %s' % self._currentStage]
            self._errorMessage = Logger.createErrorMessage(msg, err)
            self.logger.writeError(msg, err)

        session = self.getTracksSession()
        session.close()

        self._cleanup()
        SystemUtils.remove(tempPath)

        self.logger.write('\n\n[%s]: %s (%s)' % (
            'SUCCESS' if self._success else 'FAILED',
            self.__class__.__name__,
            TimeUtils.toPrettyElapsedTime(self.elapsedTime)
        ), indent=False)
Пример #2
0
    def _writeFooter(self):
        """ The final method called in the analysis process, which writes the final information
            about the analysis stage to the log file for reference. This includes basic operational
            information about performance by default. """

        elapsed = TimeUtils.getElapsedTime(
            startDateTime=self._startTime,
            endDateTime=TimeUtils.getNowDatetime(),
            toUnit=TimeUtils.MILLISECONDS)

        self.logger.write([
            '\n' + 80*'_',
            '[COMPLETE]: %s ANALYSIS STAGE' % self._label.upper(),
            '  * Elapsed Time: %s' % TimeUtils.toPrettyElapsedTime(elapsed)
        ] + self._getFooterArgs(), indent=False)
Пример #3
0
    def run(self):
        """run doc..."""

        for AnalyzerClass in self.ANALYZERS:
            a = AnalyzerClass()
            a.run()
            self.analyzers.append([a.elapsedTime, a])

            print('\n\n%s\n%s\n\n' % (80*'#', 80*'#'))

        print('%s\nANALYSIS COMPLETE:' % (80*'-'))
        for a in self.analyzers:
            print('  [%s]: %s (%s)' % (
                'SUCCESS' if a[-1].success else 'FAILED',
                TimeUtils.toPrettyElapsedTime(a[0]),
                a[-1].__class__.__name__))