예제 #1
0
파일: Logger.py 프로젝트: zzragida/Zenject
    def endHeading(self):

        if not self._headerStartTime:
            return

        delta = datetime.now() - self._headerStartTime
        totalDelta = datetime.now() - self._startTime

        message = ''

        if self._errorOccurred:
            message = 'Failed'
        else:
            message = 'Done'

        message += ' (Took %s, time: %s, total elapsed: %s)' % (
            Util.formatTimeDelta(
                delta.total_seconds()), datetime.now().strftime('%H:%M:%S'),
            Util.formatTimeDelta(totalDelta.total_seconds()))

        self._headerStartTime = None

        if self._errorOccurred:
            self._logInternal(message, LogType.HeadingFailed)
        else:
            self._logInternal(message, LogType.HeadingSucceeded)
예제 #2
0
 def getAllParameters(self):
     matches = self._config.getAll('PathVars')
     result = self._params.copy()
     for match in matches:
         assertIsType(match, dict)
         result = Util.mergeDictionaries(result, match)
     return result
예제 #3
0
 def getAllParameters(self):
     matches = self._config.getAll('PathVars')
     result = self._params.copy()
     for match in matches:
         assertIsType(match, dict)
         result = Util.mergeDictionaries(result, match)
     return result
예제 #4
0
    def runWrapper(self, runner):
        startTime = datetime.now()

        succeeded = False

        try:
            runner()
            succeeded = True

        except KeyboardInterrupt as e:
            self._log.error('Operation aborted by user by hitting CTRL+C')

        except Exception as e:
            self._log.error(str(e))

            # Only print stack trace if it's a build-script error
            if not isinstance(e, ProcessErrorCodeException) and not isinstance(e, ProcessTimeoutException):
                if MiscUtil.isRunningAsExe():
                    self._log.noise('\n' + traceback.format_exc())
                else:
                    self._log.debug('\n' + traceback.format_exc())

        totalSeconds = (datetime.now()-startTime).total_seconds()
        totalSecondsStr = Util.formatTimeDelta(totalSeconds)

        if succeeded:
            self._log.good('Operation completed successfully.  Took ' + totalSecondsStr + '.\n')
        else:
            self._log.info('Operation completed with errors.  Took ' + totalSecondsStr + '.\n')

        return succeeded
예제 #5
0
    def runWrapper(self, runner):
        startTime = datetime.now()

        succeeded = False

        try:
            runner()
            succeeded = True

        except KeyboardInterrupt as e:
            self._log.endHeading()
            self._log.error('Operation aborted by user by hitting CTRL+C')

        except Exception as e:
            self._log.endHeading()
            self._log.error(str(e))

            if self._log.currentHeading:
                self._log.error("Failed while executing '" + self._log.currentHeading + "'")

            # Only print stack trace if it's a build-script error
            if not isinstance(e, ProcessErrorCodeException) and not isinstance(e, ProcessTimeoutException):
                self._log.debug('\n' + traceback.format_exc())

        totalSeconds = (datetime.now()-startTime).total_seconds()
        totalSecondsStr = Util.formatTimeDelta(totalSeconds)

        if succeeded:
            self._log.finished('Operation completed successfully.  Took ' + totalSecondsStr + '.\n')
        else:
            self._log.finished('Operation completed with errors.  Took ' + totalSecondsStr + '.\n')

        return succeeded
예제 #6
0
    def __exit__(self, type, value, traceback):
        assertThat(self._log.hasHeading)

        assertIsEqual(self._log._headingBlocks.pop(), self)

        delta = datetime.now() - self._startTime
        totalDelta = datetime.now() - self._log.totalStartTime

        errorOccurred = type != None

        message = '{0} {1} (Took {2}, time: {3}, total elapsed: {4})'.format(
            'Failed during task: ' if errorOccurred else 'Finished',
            self._message[0].lower() + self._message[1:],
            Util.formatTimeDelta(delta.total_seconds()),
            datetime.now().strftime('%H:%M:%S'),
            Util.formatTimeDelta(totalDelta.total_seconds()))

        self._log._logInternal(message, LogType.Error if errorOccurred else LogType.HeadingEnd)
예제 #7
0
    def __exit__(self, type, value, traceback):
        assertThat(self._log.hasHeading)

        assertIsEqual(self._log._headingBlocks.pop(), self)

        delta = datetime.now() - self._startTime
        totalDelta = datetime.now() - self._log.totalStartTime

        errorOccurred = type != None

        message = "{0} {1} (Took {2}, time: {3}, total elapsed: {4})".format(
            "Failed during task: " if errorOccurred else "Finished",
            self._message[0].lower() + self._message[1:],
            Util.formatTimeDelta(delta.total_seconds()),
            datetime.now().strftime("%H:%M:%S"),
            Util.formatTimeDelta(totalDelta.total_seconds()),
        )

        self._log._logInternal(message, LogType.Error if errorOccurred else LogType.HeadingEnd)
예제 #8
0
파일: Config.py 프로젝트: AcamTech/Zenject
    def tryGetDictionary(self, fallback, *args):
        matches = self.getAll(*args)

        if len(matches) == 0:
            return fallback

        result = {}

        for match in matches:
            assertIsType(match, dict, "Unexpected type for yaml property '{0}'", self._propNameToString(args))
            result = Util.mergeDictionaries(result, match)

        return result
예제 #9
0
파일: Config.py 프로젝트: tinyogre/Projeny
    def tryGetDictionary(self, fallback, *args):
        matches = self.getAll(*args)

        if len(matches) == 0:
            return fallback

        result = {}

        for match in matches:
            assertIsType(match, dict, "Unexpected type for yaml property '{0}'", self._propNameToString(args))
            result = Util.mergeDictionaries(result, match)

        return result
예제 #10
0
파일: Logger.py 프로젝트: AcamTech/Zenject
    def endHeading(self):

        if not self._headerStartTime:
            return

        delta = datetime.now() - self._headerStartTime
        totalDelta = datetime.now() - self._startTime

        message = ''

        if self._errorOccurred:
            message = 'Failed'
        else:
            message = 'Done'

        message += ' (Took %s, time: %s, total elapsed: %s)' % (Util.formatTimeDelta(delta.total_seconds()), datetime.now().strftime('%H:%M:%S'), Util.formatTimeDelta(totalDelta.total_seconds()))

        self._headerStartTime = None

        if self._errorOccurred:
            self._logInternal(message, LogType.HeadingFailed)
        else:
            self._logInternal(message, LogType.HeadingSucceeded)