Beispiel #1
0
 def elapsedTime(self):
     if not self._startTime:
         return 0
     return TimeUtils.getElapsedTime(
         startDateTime=self._startTime,
         endDateTime=TimeUtils.getNowDatetime(),
         toUnit=TimeUtils.MILLISECONDS)
Beispiel #2
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)
Beispiel #3
0
    def analyze(self):
        """ Executes the analysis process for this stage, which consists largely of calling the
            analysis hook methods in their specified order. """

        # resets the cache
        self.cache.unload()

        self._startTime = TimeUtils.getNowDatetime()
        self._writeHeader()
        self._preAnalyze()
        self._analyze()
        self._postAnalyze()
        self._writeFooter()
    def _putFile(self, sourcePath, key):
        self._bucket.putFile(
            key=key,
            filename=sourcePath,
            policy=S3Bucket.PRIVATE if self._flexData.debug else S3Bucket.PUBLIC_READ)

        expires  = TimeUtils.getNowDatetime()
        expires += datetime.timedelta(days=30)
        if self._flexData.debug:
            url = self._bucket.generateExpiresUrl(key, expires)
        else:
            url = 'http://' + self._bucket.bucketName + '/' + key

        return url
Beispiel #5
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)
    def __init__(self, projectData, bucket =None, uploadFolder =None, **kwargs):
        """Creates a new instance of BuildPackageUploader."""
        self._flexData = projectData

        if uploadFolder is None:
            self._uploadFolder = '/'.join([
                'downloads',
                'debug' if self._flexData.debug else 'release',
                TimeUtils.getNowDatetime().strftime('%b-%d-%y')])
        else:
            self._uploadFolder = uploadFolder

        if not self._uploadFolder.endswith('/'):
            self._uploadFolder += '/'

        self._bucket = bucket if bucket else self._flexData.createBucket()
    def _handleCompilationComplete(self, event):
        snap = self._buildSnapshot

        if self._package and event.target.success:

            # If this was an appended package then prior to storing the snapshot the combined
            # platforms should be stored as the result instead of the platforms stored in this
            # particular case
            if 'combinedPlatforms' in snap:
                platforms = snap['combinedPlatforms']
                snap['platforms'] = platforms
                del snap['combinedPlatforms']
            else:
                platforms = snap['platforms']

            # Any package uploads conducted as part of the compilation process should be included
            # in the build snapshot for reference to prevent uploading them again in the future
            output = event.target.output
            if 'urls' in output:
                snap['platformUploads'] = DictUtils.merge(
                    snap['platformUploads'], output['urls'])

            self._storeBuildSnapshot()

            FileUtils.putContents('\t'.join([
                    TimeUtils.getNowDatetime().strftime('[%a %m-%d %H:%M]'),
                    'DSK' if platforms.get(FlexProjectData.AIR_PLATFORM, False) else '---',
                    'AND' if platforms.get(FlexProjectData.ANDROID_PLATFORM, False) else '---',
                    'IOS' if platforms.get(FlexProjectData.IOS_PLATFORM, False) else '---',
                    'WIN' if platforms.get(FlexProjectData.WINDOWS_PLATFORM, False) else '---',
                    'MAC' if platforms.get(FlexProjectData.MAC_PLATFORM, False) else '---',
                    '<<' + snap['versionInfo']['number'] + '>>',
                    '<<' + snap['versionInfo']['label'] + '>>' ]) + '\n',
                self._settingsEditor.buildLogFilePath,
                True )

            self._settingsEditor.reset()
            self._settingsEditor.populate()
            self._updateSettings()

        self._handleRemoteThreadComplete(event)
        self._package = False