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


Python LOG.oops方法代码示例

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


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

示例1: read_send_queue

# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import oops [as 别名]
    def read_send_queue(self):
        octets = ""

        while self.send_queue:
            octets = self.send_queue[0]
            if isinstance(octets, basestring):
                # remove the piece in any case
                self.send_queue.popleft()
                if octets:
                    break
            else:
                octets = octets.read(MAXBUF)
                if octets:
                    break
                # remove the file-like when it is empty
                self.send_queue.popleft()

        if octets:
            if type(octets) == types.UnicodeType:
                LOG.oops("Received unicode input")
                octets = octets.encode("utf-8")
            if self.encrypt:
                octets = self.encrypt(octets)

        return octets
开发者ID:ClaudioArtusio,项目名称:neubot,代码行数:27,代码来源:stream.py

示例2: closed

# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import oops [as 别名]
    def closed(self, exception=None):
        if self.close_complete:
            return

        self.close_complete = True

        if exception:
            LOG.error("* Connection %s: %s" % (self.logname, exception))
        elif self.eof:
            LOG.debug("* Connection %s: EOF" % (self.logname))
        else:
            LOG.debug("* Closed connection %s" % (self.logname))

        self.connection_lost(exception)
        self.parent.connection_lost(self)

        atclosev, self.atclosev = self.atclosev, set()
        for func in atclosev:
            try:
                func(self, exception)
            except (KeyboardInterrupt, SystemExit):
                raise
            except:
                LOG.oops("Error in atclosev")

        if self.measurer:
            self.measurer.unregister_stream(self)

        self.send_octets = None
        self.send_ticks = 0
        self.recv_ticks = 0
        self.sock.soclose()
开发者ID:ClaudioArtusio,项目名称:neubot,代码行数:34,代码来源:stream.py

示例3: run

# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import oops [as 别名]
def run(poller, conf):
    """ Start the client or server-side of the negotiate module """

    if not "negotiate.listen" in conf:
        LOG.oops("Thou shall pass 'negotiate.listen' to negotiate")

    _SERVER = _ServerNegotiate(None)
    HTTP_SERVER.register_child(_SERVER, "/negotiate/")
    HTTP_SERVER.register_child(_SERVER, "/collect/")
开发者ID:ClaudioArtusio,项目名称:neubot,代码行数:11,代码来源:negotiate.py

示例4: unchoke

# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import oops [as 别名]
 def unchoke(self, m):
     btid = _make_btid(m["ident"])
     if btid not in AUTH_PEERS:
         self._streams[m["stream"]] = btid
         m["stream"].atclose(self._at_close)
         target_bytes = int(m["request_body"]["target_bytes"])
         if target_bytes < 0:
             raise RuntimeError("Invalid target_bytes")
         AUTH_PEERS[btid] = {"target_bytes": target_bytes}
     else:
         LOG.oops("Multiple negotiation requests")
开发者ID:ClaudioArtusio,项目名称:neubot,代码行数:13,代码来源:negotiate.py

示例5: run

# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import oops [as 别名]
def run(poller, conf):

    # Make sure the conf makes sense before we go
    config.finalize_conf(conf)

    if conf["bittorrent.listen"]:
        if conf["bittorrent.negotiate"]:

            #
            # We assume that the caller has already started
            # the HTTP server and that it contains our negotiator
            # so here we just bring up the test server.
            #
            server = ServerPeer(poller)
            server.configure(conf)
            server.listen((conf["bittorrent.address"],
                           conf["bittorrent.port"]))

        else:
            server = PeerNeubot(poller)
            server.configure(conf)
            server.listen((conf["bittorrent.address"],
                           conf["bittorrent.port"]))

    else:

        #
        # Make sure there is someone ready to receive the
        # "testdone" event.  If there is noone it is a bug
        # none times out of ten.
        #
        if not NOTIFIER.is_subscribed("testdone"):
            LOG.oops("The 'testdone' event is not subscribed")

        if conf["bittorrent.negotiate"]:
            client = BitTorrentClient(poller)
            client.configure(conf)

            #
            # The rendezvous client uses this hidden variable
            # to pass us the URI to connect() to (the rendezvous
            # returns an URI, not address and port).
            #
            uri = None
            if "bittorrent._uri" in conf:
                uri = conf["bittorrent._uri"]

            client.connect_uri(uri)

        else:
            client = PeerNeubot(poller)
            client.configure(conf)
            client.connect((conf["bittorrent.address"],
                           conf["bittorrent.port"]))
开发者ID:DavideAllavena,项目名称:neubot,代码行数:56,代码来源:__init__.py

示例6: _send_response

# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import oops [as 别名]
 def _send_response(self, m):
     try:
         m["parent"].send_response(m)
     except (KeyboardInterrupt, SystemExit):
         raise
     except Exception, e:
         LOG.oops("send_response() failed: %s" % str(e))
         try:
             m["stream"].close()
         except (KeyboardInterrupt, SystemExit):
             raise
         except Exception, e:
             LOG.oops("close() failed: %s" % str(e))
开发者ID:ClaudioArtusio,项目名称:neubot,代码行数:15,代码来源:negotiate.py

示例7: collect_allowed

# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import oops [as 别名]
def collect_allowed(m):

    ''' Returns True if we are allowed to collect a result into the
        database, and False otherwise '''

    if type(m) != types.DictType:
        #
        # XXX This is a shame therefore put the oops() and hope that
        # it does its moral suasion job as expected.
        #
        LOG.oops("TODO: please pass me a dictionary!", LOG.debug)
        m = m.__dict__
    return (not utils.intify(m["privacy_informed"])
            or utils.intify(m["privacy_can_collect"]))
开发者ID:ClaudioArtusio,项目名称:neubot,代码行数:16,代码来源:privacy.py

示例8: Exception

# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import oops [as 别名]
    LOG.warning("testing neubot logger -- This is an warning message")
    LOG.info("testing neubot logger -- This is an info message")
    LOG.debug("testing neubot logger -- This is a debug message")
    print compat.json.dumps(LOG.listify())

    try:
        raise Exception("Testing LOG.exception")
    except (KeyboardInterrupt, SystemExit):
        raise
    except:
        LOG.exception()
        LOG.exception(func=LOG.warning)

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

    LOG.oops("Testing the new oops feature")

    # Testing variadic args
    logging.warning("WARNING %s", "variadic warning")
    LOG.warning("WARNING %s", "variadic warning")

    LOG.redirect()

    LOG.error("testing neubot logger -- This is an error message")
    LOG.warning("testing neubot logger -- This is an warning message")
    LOG.info("testing neubot logger -- This is an info message")
    LOG.debug("testing neubot logger -- This is a debug message")
开发者ID:DavideAllavena,项目名称:neubot,代码行数:32,代码来源:log.py

示例9: atclose

# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import oops [as 别名]
 def atclose(self, func):
     if func in self.atclosev:
         LOG.oops("Duplicate atclose(): %s" % func)
     self.atclosev.add(func)
开发者ID:DavideAllavena,项目名称:neubot,代码行数:6,代码来源:stream.py

示例10: compose

# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import oops [as 别名]
    def compose(self, **kwargs):
        ''' Prepare a request on the client side '''
        self.method = kwargs.get("method", "")

        if kwargs.get("uri", ""):
            self.uri = kwargs.get("uri", "")
            (self.scheme, self.address,
             self.port, self.pathquery) = urlsplit(self.uri)
            self["host"] = self.address + ":" + self.port
        else:
            self.scheme = kwargs.get("scheme", "")
            self.address = kwargs.get("address", "")
            self.port = kwargs.get("port", "")
            self.pathquery = kwargs.get("pathquery", "")
            if self.method:
                #
                # "A client MUST include a Host header field in all HTTP/1.1
                # request messages.  If the requested URI does not include
                # an Internet host name for the service being requested, then
                # the Host header field MUST be given with an empty value."
                #               -- RFC 2616
                #
                self["host"] = kwargs.get("host", "")
                if not self["host"]:
                    LOG.oops("Missing host header")

        self.code = kwargs.get("code", "")
        self.reason = kwargs.get("reason", "")
        self.protocol = kwargs.get("protocol", "HTTP/1.1")

        if kwargs.get("nocache", True):
            if self.method:
                self["pragma"] = "no-cache"
            self["cache-control"] = "no-cache"

        if kwargs.get("date", True):
            self["date"] = email.utils.formatdate(usegmt=True)

        if not kwargs.get("keepalive", True):
            self["connection"] = "close"

        #
        # Curl(1) does not enter into up_to_eof mode unless a
        # content-type is specified, for this reason I've added
        # an OOPS below.
        # TODO Looking again at RFC2616 after adding this bits
        # realized that another patch is due to make the code
        # that deals with body and length better.
        #
        if kwargs.get("up_to_eof", False):
            if not "mimetype" in kwargs:
                LOG.oops("up_to_eof without mimetype")
            self["content-type"] = kwargs.get("mimetype",
                                       "text/plain")

        elif kwargs.get("body", None):
            self.body = kwargs.get("body", None)
            if isinstance(self.body, basestring):
                self.length = len(self.body)
            else:
                utils.safe_seek(self.body, 0, os.SEEK_END)
                self.length = self.body.tell()
                utils.safe_seek(self.body, 0, os.SEEK_SET)
            self["content-length"] = str(self.length)
            if kwargs.get("mimetype", ""):
                self["content-type"] = kwargs.get("mimetype", "")

        elif kwargs.get("chunked", None):
            self.body = kwargs.get("chunked", None)
            self.length = -1
            self["transfer-encoding"] = "chunked"
            if kwargs.get("mimetype", ""):
                self["content-type"] = kwargs.get("mimetype", "")

        else:
            self["content-length"] = "0"

        self.family = kwargs.get("family", socket.AF_INET)
开发者ID:DavideAllavena,项目名称:neubot,代码行数:80,代码来源:message.py

示例11: compose

# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import oops [as 别名]
    def compose(self, **kwargs):
        self.method = kwargs.get("method", "")

        if kwargs.get("uri", ""):
            self.uri = kwargs.get("uri", "")
            (self.scheme, self.address,
             self.port, self.pathquery) = urlsplit(self.uri)
            self["host"] = self.address + ":" + self.port
        else:
            self.scheme = kwargs.get("scheme", "")
            self.address = kwargs.get("address", "")
            self.port = kwargs.get("port", "")
            self.pathquery = kwargs.get("pathquery", "")
            if self.method:
                #
                # "A client MUST include a Host header field in all HTTP/1.1
                # request messages.  If the requested URI does not include
                # an Internet host name for the service being requested, then
                # the Host header field MUST be given with an empty value."
                #               -- RFC 2616
                #
                self["host"] = kwargs.get("host", "")
                if not self["host"]:
                    LOG.oops("Missing host header")

        self.code = kwargs.get("code", "")
        self.reason = kwargs.get("reason", "")
        self.protocol = kwargs.get("protocol", "HTTP/1.1")

        if kwargs.get("nocache", True):
            if self.method:
                self["pragma"] = "no-cache"
            self["cache-control"] = "no-cache"

        if kwargs.get("date", True):
            self["date"] = date()

        if not kwargs.get("keepalive", True):
            self["connection"] = "close"

        if kwargs.get("body", None):
            self.body = kwargs.get("body", None)
            if isinstance(self.body, basestring):
                self.length = len(self.body)
            else:
                utils.safe_seek(self.body, 0, os.SEEK_END)
                self.length = self.body.tell()
                utils.safe_seek(self.body, 0, os.SEEK_SET)
            self["content-length"] = str(self.length)
            if kwargs.get("mimetype", ""):
                self["content-type"] = kwargs.get("mimetype", "")

        elif kwargs.get("chunked", None):
            self.body = kwargs.get("chunked", None)
            self.length = -1
            self["transfer-encoding"] = "chunked"
            if kwargs.get("mimetype", ""):
                self["content-type"] = kwargs.get("mimetype", "")

        else:
            self["content-length"] = "0"

        self.family = kwargs.get("family", socket.AF_INET)
开发者ID:ClaudioArtusio,项目名称:neubot,代码行数:65,代码来源:message.py


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