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


Python LOG.progress方法代码示例

本文整理汇总了Python中neubot.log.LOG.progress方法的典型用法代码示例。如果您正苦于以下问题:Python LOG.progress方法的具体用法?Python LOG.progress怎么用?Python LOG.progress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在neubot.log.LOG的用法示例。


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

示例1: connection_ready

# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import progress [as 别名]
    def connection_ready(self, stream):
        LOG.progress()

        m = compat.RendezvousRequest()
        m.accept.append("speedtest")
        m.accept.append("bittorrent")
        m.version = CONFIG["rendezvous.client.version"]

        request = Message()
        request.compose(method="GET", pathquery="/rendezvous",
          mimetype="text/xml", keepalive=False, host=self.host_header,
          body=marshal.marshal_object(m, "text/xml"))

        stream.send_request(request)
开发者ID:ClaudioArtusio,项目名称:neubot,代码行数:16,代码来源:client.py

示例2: got_response

# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import progress [as 别名]
 def got_response(self, stream, request, response):
     if self.finished:
         stream.close()
         return
     LOG.progress()
     if response.code not in ("200", "206"):
         stream.close()
         self.cleanup("bad response code")
     else:
         try:
             self.child.got_response(stream, request, response)
         except (KeyboardInterrupt, SystemExit):
             raise
         except:
             LOG.exception()
             stream.close()
             self.cleanup("unexpected exception")
         else:
             self.streams.append(stream)
             self.update()
开发者ID:DavideAllavena,项目名称:neubot,代码行数:22,代码来源:client.py

示例3: connection_ready

# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import progress [as 别名]
    def connection_ready(self, stream):
        LOG.progress()

        m = compat.RendezvousRequest()
        m.accept.append("speedtest")
        m.accept.append("bittorrent")
        m.version = CONFIG["rendezvous.client.version"]
        m.privacy_informed = CONFIG["privacy.informed"]
        m.privacy_can_collect = CONFIG["privacy.can_collect"]
        m.privacy_can_share = CONFIG["privacy.can_publish"]  # XXX

        request = Message()
        request.compose(
            method="GET",
            pathquery="/rendezvous",
            mimetype="text/xml",
            keepalive=False,
            host=self.host_header,
            body=marshal.marshal_object(m, "text/xml"),
        )

        stream.send_request(request)
开发者ID:DavideAllavena,项目名称:neubot,代码行数:24,代码来源:client.py

示例4: assert

# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import progress [as 别名]
import logging
import sys

if __name__ == "__main__":
    sys.path.insert(0, ".")

from neubot.log import LOG
from neubot.log import _log_info
from neubot import compat

if __name__ == "__main__":
    # Make sure the hackish name substitution works
    assert(logging.info == _log_info)

    LOG.start("Testing the in-progress feature")
    LOG.progress("...")
    LOG.progress()
    LOG.complete("success!")

    logging.info("INFO w/ logging.info")
    # The following should work because it should not interpolate
    logging.debug("DEBUG w/ logging.debug", "ciao")
    logging.warning("WARNING w/ logging.warning")
    logging.error("ERROR w/ logging.error")

    LOG.verbose()

    logging.info("INFO w/ logging.info")
    logging.debug("DEBUG w/ logging.debug")
    logging.warning("WARNING w/ logging.warning")
    logging.error("ERROR w/ logging.error")
开发者ID:DavideAllavena,项目名称:neubot,代码行数:33,代码来源:log.py

示例5: update

# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import progress [as 别名]
    def update(self):
        if self.finished:
            return

        #
        # Decide whether we can transition to the next phase of
        # the speedtest or not.  Fall through to next request if
        # needed, or return to the caller and rewind the stack.
        #

        ostate = self.state

        if not self.state:
            self.state = "negotiate"
            del QUEUE_HISTORY[:]

        elif self.state == "negotiate":
            if self.conf.get("speedtest.client.unchoked", False):
                LOG.complete("authorized to take the test\n")
                self.state = "latency"
            elif "speedtest.client.queuepos" in self.conf:
                queuepos = self.conf["speedtest.client.queuepos"]
                LOG.complete("waiting in queue, pos %s\n" % queuepos)
                STATE.update("negotiate", {"queue_pos": queuepos})
                QUEUE_HISTORY.append(queuepos)

        elif self.state == "latency":
            tries = self.conf.get("speedtest.client.latency_tries", 10)
            if tries == 0:
                # Calculate average latency
                latency = self.conf["speedtest.client.latency"]
                latency = sum(latency) / len(latency)
                self.conf["speedtest.client.latency"] = latency
                # Advertise the result
                STATE.update("test_latency", utils.time_formatter(latency))
                LOG.complete("done, %s\n" % utils.time_formatter(latency))
                self.state = "download"
            else:
                self.conf["speedtest.client.latency_tries"] = tries - 1

        elif self.state in ("download", "upload"):
            if len(self.streams) == self.conf.get("speedtest.client.nconn", 1):

                # Calculate average speed
                speed = self.conf["speedtest.client.%s" % self.state]
                elapsed = (max(map(lambda t: t[1], speed)) -
                  min(map(lambda t: t[0], speed)))
                speed = sum(map(lambda t: t[2], speed)) / elapsed
                LOG.progress(".[%s,%s]." % (utils.time_formatter(elapsed),
                       utils.speed_formatter(speed)))

                #
                # O(N) loopless adaptation to the channel w/ memory
                # TODO bittorrent/peer.py implements an enhanced version
                # of this algorithm, with a cap to the max number of
                # subsequent tests.  In addition to that, the bittorrent
                # code also anticipates the update of target_bytes.
                #
                if elapsed > LO_THRESH:
                    ESTIMATE[self.state] *= TARGET/elapsed
                    self.conf["speedtest.client.%s" % self.state] = speed
                    # Advertise
                    STATE.update("test_%s" % self.state,
                      utils.speed_formatter(speed))
                    LOG.complete("done, %s\n" % utils.speed_formatter(speed))
                    if self.state == "download":
                        self.state = "upload"
                    else:
                        self.state = "collect"
                elif elapsed > LO_THRESH/3:
                    del self.conf["speedtest.client.%s" % self.state]
                    ESTIMATE[self.state] *= TARGET/elapsed
                else:
                    del self.conf["speedtest.client.%s" % self.state]
                    ESTIMATE[self.state] *= 2

            else:
                # Wait for all pending requests to complete
                return

        elif self.state == "collect":
            LOG.complete()
            self.cleanup()
            return

        else:
            raise RuntimeError("Invalid state")

        #
        # Perform state transition and run the next phase of the
        # speedtest.  Not all phases need to employ all the connection
        # with the upstream server.
        #

        if self.state == "negotiate":
            ctor, justone = ClientNegotiate, True
        elif self.state == "latency":
            ctor, justone = ClientLatency, True
        elif self.state == "download":
            ctor, justone = ClientDownload, False
#.........这里部分代码省略.........
开发者ID:DavideAllavena,项目名称:neubot,代码行数:103,代码来源:client.py


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