Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
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
Exemplo n.º 4
0
    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
Exemplo n.º 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