当前位置: 首页>>代码示例>>Python>>正文


Python util.untilConcludes函数代码示例

本文整理汇总了Python中twisted.python.util.untilConcludes函数的典型用法代码示例。如果您正苦于以下问题:Python untilConcludes函数的具体用法?Python untilConcludes怎么用?Python untilConcludes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了untilConcludes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: emit

    def emit(self, eventDict):
        text = textFromEventDict(eventDict)
        if text is None:
            return

        timeStr = self._colorize(self.formatTime(eventDict["time"]), ColoredFileLogObserver.GREY_NORMAL)
        fmtDict = {"system": eventDict["system"], "text": text.replace("\n", "\n\t")}
        systemStr = ""
        systemStr = self._colorize(_safeFormat("[%(system)s]", fmtDict), ColoredFileLogObserver.GREY_NORMAL)
        textStr = _safeFormat("%(text)s", fmtDict)

        if textStr.startswith("SSH"):
            t = textStr.find("STDERR:")
            if t != -1:
                textStr = self._colorize(textStr[t + 8 :], ColoredFileLogObserver.RED_BOLD)
            else:
                textStr = self._colorize(textStr[textStr.find("STDOUT:") + 8 :], ColoredFileLogObserver.GREEN_BOLD)
            # only text for incoming data
            msgStr = textStr + "\n"
        else:
            # add system to the local logs
            # TODO: Make system more useful, not just "SSHChannel...".
            msgStr = systemStr + " " + textStr + "\n"

        util.untilConcludes(self.write, timeStr + " " + msgStr)
        util.untilConcludes(self.flush)  # Hoorj!
开发者ID:NielsZeilemaker,项目名称:gumby,代码行数:26,代码来源:run.py

示例2: emit

    def emit(self, eventDict):
        edm = eventDict['message']
        if not edm:
            if eventDict['isError'] and eventDict.has_key('failure'):
                text = eventDict['failure'].getTraceback()
            elif eventDict.has_key('format'):
                try:
                    text = eventDict['format'] % eventDict
                except KeyboardInterrupt:
                    raise
                except:
                    try:
                        text = ('Invalid format string in log message: %s'
                                % eventDict)
                    except:
                        text = 'UNFORMATTABLE OBJECT WRITTEN TO LOG, MESSAGE LOST'
            else:
                # we don't know how to log this
                return
        else:
            text = ' '.join(map(str, edm))

        timeStr = time.strftime(self.timeFormat, time.localtime(eventDict['time']))
        fmtDict = {'system': eventDict['system'], 'text': text.replace("\n", "\n\t")}
        msgStr = " [%(system)s] %(text)s\n" % fmtDict

        util.untilConcludes(self.write, timeStr + msgStr)
        util.untilConcludes(self.flush)  # Hoorj!
开发者ID:pwarren,项目名称:AGDeviceControl,代码行数:28,代码来源:log.py

示例3: emit

    def emit(self, eventDict):
        if not eventDict.has_key('level'):
            if eventDict.has_key('isError') and eventDict['isError']:
                eventDict['level'] = ERROR

            else:
                eventDict['level'] = TRACE

        if eventDict['level'] < self.level:
            return

        text = log.textFromEventDict(eventDict)
        if text is None:
            return

        text = text.rstrip()
        text = text.expandtabs()
        text += '\n'
        text = text.encode('utf-8')

        util.untilConcludes(self.write, text)
        util.untilConcludes(self.flush)
        
        if eventDict['level'] >= CRITICAL:
            self.reactor.stop()
开发者ID:drhinehart,项目名称:b07bot,代码行数:25,代码来源:log.py

示例4: _emit

 def _emit(self, params):
     level = params.get('level', LOG_DEBUG)
     if level > self.verbosity:
         return
     msg = self._formatMessage(params) + '\r\n'
     util.untilConcludes(self.write, msg)
     util.untilConcludes(self.flush)
开发者ID:msfrank,项目名称:Higgins,代码行数:7,代码来源:logger.py

示例5: write

 def write(self, output):
   """Write a gec error report, possibly overwriting a previous one."""
   self.errorId = (self.errorId + 1) % GentleGecLogObserver.MAX_ERRORS
   filename = os.path.join(self._GecHandler__path, '%d-%d.gec.json' % (self.baseName, self.errorId))
   with open(filename, 'w') as f:
     util.untilConcludes(f.write, output)
     util.untilConcludes(f.flush)
开发者ID:Cue,项目名称:greplin-exception-catcher,代码行数:7,代码来源:twistedLog.py

示例6: emit

    def emit(self, eventDict):
        """
        Extended base class' 'emit' method by log level support.
        """
        if eventDict['isError']:
            level = logging.ERROR
        elif 'level' in eventDict:
            level = eventDict['level']
        else:
            level = logging.INFO
        if level < self.log_level:
            return

        text = tx_log.textFromEventDict(eventDict)
        if text is None:
            return

        time_str = self.formatTime(eventDict['time'])
        fmt_dict = {
            'level': logging.getLevelName(level),
            'system': eventDict['system'],
            'text': text.replace("\n", "\n\t")
        }
        msg_str = tx_log._safeFormat("%(level)s:[%(system)s]:%(text)s\n",
                                     fmt_dict)

        tx_util.untilConcludes(self.write, time_str + " " + msg_str)
        tx_util.untilConcludes(self.flush)
开发者ID:Kamyhin,项目名称:il2ds-events-commander,代码行数:28,代码来源:log.py

示例7: emit

    def emit(self, eventDict):
        text = txlog.textFromEventDict(eventDict)
        if text is None:
            return

        util.untilConcludes(self.write, "%s\n" % text)
        util.untilConcludes(self.flush)  # Hoorj!
开发者ID:ThisIsNotOfficialCodeItsJustForks,项目名称:ooni-backend,代码行数:7,代码来源:log.py

示例8: emit

    def emit(self, eventDict):
        text = textFromEventDict(eventDict)
        if text is None:
            return

        timeStr = self.formatTime(eventDict['time'])
        fmtDict = {'system': eventDict['system'], 'text': text.replace("\n",
            "\n\t")}
        level = "INFO"
        # in the future twisted version, a new logging system might have better
        # support for logging levels. 
        logLevelMapping = {50: "CRITICAL", 40: "ERROR", 30: "WARNING", 20:
                "INFO", 10: "DEBUG", 0: "NOTSET"}
        if not "log_level" in eventDict:
            if "logLevel" in eventDict:
                try:
                    level = logLevelMapping[eventDict["logLevel"]]
                except KeyError:
                    level = None
            elif eventDict["isError"]:
                level = "CRITICAL" 
            else:
                level = "INFO"

        msgStr = _safeFormat("[%(system)s] %(text)s\n", fmtDict)

        util.untilConcludes(self.write, timeStr + " <" + level + "> " + msgStr)
        util.untilConcludes(self.flush)  # Hoorj!
开发者ID:ArthurJiang,项目名称:PiSensorNetwork,代码行数:28,代码来源:myObserver.py

示例9: emit

    def emit(self, eventDict):
        """
        Extends method of the base class by providing support for log level.
        """
        if eventDict['isError']:
            level = logging.ERROR
        elif 'level' in eventDict:
            level = eventDict['level']
        else:
            level = logging.INFO
        if level < self.log_level:
            return

        text = log.textFromEventDict(eventDict)
        if text is None:
            return

        time_str = self.formatTime(eventDict['time'])
        fmt_dict = {
            'level': logging.getLevelName(level),
            'system': eventDict['system'],
            'text': text.replace("\n", "\n\t")
        }
        msg_str = log._safeFormat(
            "%(level)8s:[%(system)s]: %(text)s\n", fmt_dict)

        util.untilConcludes(self.write, "{0} {1}".format(time_str, msg_str))
        util.untilConcludes(self.flush)
开发者ID:oblalex,项目名称:tx-logging,代码行数:28,代码来源:observers.py

示例10: err

def err(_stuff = None, _why = None, **kw):
    if logger is None:
        util.untilConcludes(stderr_write, repr((_stuff, _why, kw)))
        util.untilConcludes(stderr_flush)

    else:
        logger.err(_stuff, _why, **kw)
开发者ID:jcollie,项目名称:txHA,代码行数:7,代码来源:log.py

示例11: emit

    def emit(self, eventDict):
        if 'failure' in eventDict:
            vf = eventDict['failure']
            e_t, e_v, e_tb = vf.type, vf.value, vf.getTracebackObject()
            sys.excepthook(e_t, e_v, e_tb)

        text = twlog.textFromEventDict(eventDict)
        if text is None:
            return

        timeStr = self.formatTime(eventDict['time'])
        fmtDict = {'system': eventDict['system'], 'text': text.replace("\n", "\n\t")}
        msgStr = twlog._safeFormat("[%(system)s] %(text)s\n", fmtDict)

        if GLLogObserver.suppressed == GLLogObserver.limit_suppressed:
            GLLogObserver.suppressed = 0
            GLLogObserver.limit_suppressed += 5
            GLLogObserver.last_exception_msg = ""

        try:
            # in addition to escape sequence removal on logfiles we also quote html chars
            util.untilConcludes(self.write, timeStr + " " + log_encode_html(msgStr))
            util.untilConcludes(self.flush) # Hoorj!
        except Exception as excep:
            GLLogObserver.suppressed += 1
            GLLogObserver.last_exception_msg = str(excep)
开发者ID:Taipo,项目名称:GlobaLeaks,代码行数:26,代码来源:utility.py

示例12: emit

    def emit(self, eventDict):
        if eventDict["isError"]:
            level = logging.ERROR
        elif "level" in eventDict:
            level = eventDict["level"]
        else:
            level = logging.INFO
        if level < self.logLevel:
            return

        message = log.textFromEventDict(eventDict)
        if not message:
            return

        logElements = {
            "timestamp": self.formatTime(eventDict["time"]),
            "level": logging.getLevelName(level),
            "system": eventDict["system"],
            "text": message.replace("\n", "\n\t")
        }
        messageString = "{} {}".format(logElements["timestamp"],
                                       log._safeFormat("%(level)7s:[%(system)s]: %(text)s\n", logElements))
        print messageString.replace("\n", "")
        util.untilConcludes(self.write, messageString)
        util.untilConcludes(self.flush)
开发者ID:HubbeKing,项目名称:PyHeufyBot,代码行数:25,代码来源:logutils.py

示例13: msg

def msg(*args, **kw):
    if logger is None:
        util.untilConcludes(stderr_write, repr((args, kw)))
        util.untilConcludes(stderr_flush)

    else:
        logger.msg(*args, **kw)
开发者ID:jcollie,项目名称:txHA,代码行数:7,代码来源:log.py

示例14: emit

    def emit(self, eventDict):

        if 'failure' in eventDict:
            vf = eventDict['failure']
            e_t, e_v, e_tb = vf.type, vf.value, vf.getTracebackObject()
            sys.excepthook(e_t, e_v, e_tb)

        text = twlog.textFromEventDict(eventDict)
        if text is None:
            return

        timeStr = self.formatTime(eventDict['time'])
        fmtDict = {'system': eventDict['system'], 'text': text.replace("\n", "\n\t")}
        msgStr = twlog._safeFormat("[%(system)s] %(text)s\n", fmtDict)

        if GLLogObserver.suppressed == GLLogObserver.limit_suppressed:
            # This code path flush the status of the broken log, in the case a flood is happen
            # for few moment or in the case something goes wrong when logging below.
            log.info("!! has been suppressed %d log lines due to error flood (last error %s)" %
                     (GLLogObserver.limit_suppressed, GLLogObserver.last_exception_msg) )

            GLLogObserver.suppressed = 0
            GLLogObserver.limit_suppressed += 5
            GLLogObserver.last_exception_msg = ""

        try:
            # in addition to escape sequence removal on logfiles we also quote html chars
            util.untilConcludes(self.write, timeStr + " " + log_encode_html(msgStr))
            util.untilConcludes(self.flush) # Hoorj!
        except Exception as excep:
            GLLogObserver.suppressed += 1
            GLLogObserver.last_exception_msg = str(excep)
开发者ID:RuanAragao,项目名称:GlobaLeaks,代码行数:32,代码来源:utility.py

示例15: myFloEmit

def myFloEmit(self, eventDict):
    text = log.textFromEventDict(eventDict)
    if text is None:
        return None
    self.timeFormat = "%Y%m%d-%H:%M:%S.%f %z"
    timeStr = self.formatTime(eventDict["time"])
    util.untilConcludes(self.write, timeStr + " " + text + "\n")
    util.untilConcludes(self.flush)
开发者ID:196884,项目名称:Python,代码行数:8,代码来源:coinbase_client.py


注:本文中的twisted.python.util.untilConcludes函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。