• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python util.untilConcludes函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: send

    def send(self, event, text):
        global stderr_write
        global stderr_flush

        text += '\n'
        text = text.encode('utf-8')
        util.untilConcludes(stderr_write, text)
        util.untilConcludes(stderr_flush)
开发者ID:jcollie,项目名称:txHA,代码行数:8,代码来源:log.py


示例17: emit

 def emit(self, eventDict):
     """ah, logs should be pretty much as the app intended"""
     text = textFromEventDict(eventDict)
     if text is None:
         return
     text.replace("\n", "\n\t")
     untilConcludes(self.write, text)
     untilConcludes(self.flush)  # Hoorj!
开发者ID:ziegeer,项目名称:droned,代码行数:8,代码来源:__main__.py


示例18: _write

 def _write(self, format_string, *args):
     s = str(format_string)
     assert isinstance(s, type(''))
     if args:
         self._stream.write(s % args)
     else:
         self._stream.write(s)
     untilConcludes(self._stream.flush)
开发者ID:Shadiesna,项目名称:ooni-probe,代码行数:8,代码来源:reporter.py


示例19: wakeUp

 def wakeUp(self):
     """Send a byte to my connection.
     """
     try:
         util.untilConcludes(self.w.send, 'x')
     except socket.error, (err, msg):
         if err != errno.WSAEWOULDBLOCK:
             raise
开发者ID:BackupTheBerlios,项目名称:tf-b4rt-svn,代码行数:8,代码来源:posixbase.py


示例20: wakeUp

 def wakeUp(self):
     """Send a byte to my connection.
     """
     try:
         util.untilConcludes(self.w.send, b'x')
     except socket.error as e:
         if e.args[0] != errno.WSAEWOULDBLOCK:
             raise
开发者ID:hensing,项目名称:twisted,代码行数:8,代码来源:posixbase.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.InsensitiveDict类代码示例发布时间:2022-05-27
下一篇:
Python util.unsignedID函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap