本文整理汇总了Python中neubot.log.LOG.debug方法的典型用法代码示例。如果您正苦于以下问题:Python LOG.debug方法的具体用法?Python LOG.debug怎么用?Python LOG.debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类neubot.log.LOG
的用法示例。
在下文中一共展示了LOG.debug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connection_made
# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import debug [as 别名]
def connection_made(self, sock, rtt=0):
if rtt:
LOG.debug("ClientHTTP: latency: %s" % utils.time_formatter(rtt))
self.rtt = rtt
stream = ClientStream(self.poller)
stream.attach(self, sock, self.conf, self.measurer)
self.connection_ready(stream)
示例2: check_response
# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import debug [as 别名]
def check_response(self, response):
if response.code != "200":
raise ValueError("Bad HTTP response code")
if response["content-type"] != "application/json":
raise ValueError("Unexpected contenty type")
octets = response.body.read()
dictionary = json.loads(octets)
LOG.debug("APIStateTracker: received JSON: " +
json.dumps(dictionary, ensure_ascii=True))
if not "events" in dictionary:
return
if not "current" in dictionary:
raise ValueError("Incomplete dictionary")
t = dictionary["t"]
if not type(t) == types.IntType and not type(t) == types.LongType:
raise ValueError("Invalid type for current event time")
if t < 0:
raise ValueError("Invalid value for current event time")
self.timestamp = t
self.process_dictionary(dictionary)
示例3: _send_handshake
# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import debug [as 别名]
def _send_handshake(self):
''' Convenience function to send handshake '''
LOG.debug("> HANDSHAKE infohash=%s id=%s" %
(self.parent.infohash.encode("hex"),
self.parent.my_id.encode("hex")))
self.start_send("".join((chr(len(PROTOCOL_NAME)), PROTOCOL_NAME,
FLAGS, self.parent.infohash, self.parent.my_id)))
示例4: attach
# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import debug [as 别名]
def attach(self, parent, sock, conf):
self.parent = parent
self.conf = conf
self.filenum = sock.fileno()
self.myname = sock.getsockname()
self.peername = sock.getpeername()
self.logname = str((self.myname, self.peername))
LOG.debug("* Connection made %s" % str(self.logname))
if conf["net.stream.secure"]:
if not ssl:
raise RuntimeError("SSL support not available")
server_side = conf["net.stream.server_side"]
certfile = conf["net.stream.certfile"]
# wrap_socket distinguishes between None and ''
if not certfile:
certfile = None
ssl_sock = ssl.wrap_socket(sock, do_handshake_on_connect=False,
certfile=certfile, server_side=server_side)
self.sock = SSLWrapper(ssl_sock)
self.recv_ssl_needs_kickoff = not server_side
else:
self.sock = SocketWrapper(sock)
self.connection_made()
示例5: closed
# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import debug [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()
示例6: got_response_negotiating
# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import debug [as 别名]
def got_response_negotiating(self, stream, request, response):
m = json.loads(response.body.read())
PROPERTIES = ("authorization", "queue_pos", "real_address", "unchoked")
for k in PROPERTIES:
self.conf["_%s" % k] = m[k]
if not self.conf["_unchoked"]:
LOG.complete("done (queue_pos %d)" % m["queue_pos"])
STATE.update("negotiate", {"queue_pos": m["queue_pos"]})
self.connection_ready(stream)
else:
LOG.complete("done (unchoked)")
sha1 = hashlib.sha1()
sha1.update(m["authorization"])
self.conf["bittorrent.my_id"] = sha1.digest()
LOG.debug("* My ID: %s" % sha1.hexdigest())
self.http_stream = stream
self.negotiating = False
peer = PeerNeubot(self.poller)
peer.complete = self.peer_test_complete
peer.connection_lost = self.peer_connection_lost
peer.connection_failed = self.peer_connection_failed
peer.configure(self.conf)
peer.connect((self.http_stream.peername[0],
self.conf["bittorrent.port"]))
示例7: prettyprintbody
# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import debug [as 别名]
def prettyprintbody(self, prefix):
''' Pretty print body '''
if self["content-type"] not in ("application/json", "text/xml",
"application/xml"):
return
# Grab the whole body
if not isinstance(self.body, basestring):
body = self.body.read()
else:
body = self.body
# Decode the body
if self["content-type"] == "application/json":
string = compat.json.dumps(compat.json.loads(body),
indent=4, sort_keys=True)
elif self["content-type"] in ("text/xml", "application/xml"):
string = body
# Prettyprint
for line in string.split("\n"):
LOG.debug("%s %s" % (prefix, line.rstrip()))
# Seek to the beginning if needed
if not isinstance(self.body, basestring):
utils.safe_seek(self.body, 0)
示例8: merge_api
# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import debug [as 别名]
def merge_api(self, dictlike, database=None):
# enforce all-or-nothing
LOG.debug("config: reading properties from /api/config")
map(lambda t: self.merge_kv(t, dry=True), dictlike.iteritems())
map(self.merge_kv, dictlike.iteritems())
if database:
table_config.update(database, dictlike.iteritems())
示例9: connection_lost
# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import debug [as 别名]
def connection_lost(self, stream):
if runner_core.test_is_running():
LOG.debug("RendezVous: don't _schedule(): test in progress")
return
if self._task:
LOG.debug("RendezVous: don't _schedule(): we already have a task")
return
self._schedule()
示例10: connection_lost
# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import debug [as 别名]
def connection_lost(self, stream):
if NOTIFIER.is_subscribed("testdone"):
LOG.debug("RendezVous: don't _schedule(): test in progress")
return
if self._task:
LOG.debug("RendezVous: don't _schedule(): we already have a task")
return
self._schedule()
示例11: connection_made
# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import debug [as 别名]
def connection_made(self, sock, rtt=0):
''' Invoked when the connection is created '''
if rtt:
LOG.debug("ClientHTTP: latency: %s" % utils.time_formatter(rtt))
self.rtt = rtt
stream = ClientStream(self.poller)
stream.attach(self, sock, self.conf)
self.connection_ready(stream)
示例12: __setitem__
# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import debug [as 别名]
def __setitem__(self, key, value):
if key in self:
ovalue = self[key]
cast = utils.smart_cast(ovalue)
else:
ovalue = "(none)"
cast = utils.smart_cast(value)
value = cast(value)
LOG.debug("config: %s: %s -> %s" % (key, ovalue, value))
dict.__setitem__(self, key, value)
示例13: recv_complete
# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import debug [as 别名]
def recv_complete(self, s):
while s and not (self.close_pending or self.close_complete):
# If we don't know the length then read it
if self.left == 0:
amt = min(len(s), 4 - self.count)
self.buff.append(s[:amt])
s = buffer(s, amt)
self.count += amt
if self.count == 4:
self.left = toint("".join(self.buff))
if self.left == 0:
LOG.debug("< KEEPALIVE")
del self.buff[:]
self.count = 0
elif self.count > 4:
raise RuntimeError("Invalid self.count")
# Bufferize and pass upstream messages
elif self.left > 0:
amt = min(len(s), self.left)
if self.count <= self.smallmessage:
self.buff.append(s[:amt])
else:
if self.buff:
self._got_message_start("".join(self.buff))
# This means "big message"
del self.buff[:]
mp = buffer(s, 0, amt)
self._got_message_part(mp)
s = buffer(s, amt)
self.left -= amt
self.count += amt
if self.left == 0:
# Small or big message?
if self.buff:
self._got_message("".join(self.buff))
else:
self._got_message_end()
del self.buff[:]
self.count = 0
elif self.left < 0:
raise RuntimeError("Invalid self.left")
# Something's wrong
else:
raise RuntimeError("Invalid self.left")
if not (self.close_pending or self.close_complete):
self.start_recv()
示例14: update
# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import debug [as 别名]
def update(self, name, event=None, publish=True):
if not event:
event = {}
if name in STATES:
self._current = name
self._t = self._T()
self._events[name] = event
LOG.debug("state: %s %s" % (name, event))
if publish:
self._publish(STATECHANGE, self._t)
示例15: send_piece
# 需要导入模块: from neubot.log import LOG [as 别名]
# 或者: from neubot.log.LOG import debug [as 别名]
def send_piece(self, index, begin, block):
if not isinstance(block, basestring):
length = utils.file_length(block)
LOG.debug("> PIECE %d %d len=%d" % (index, begin, length))
preamble = struct.pack("!cII", PIECE, index, begin)
l = len(preamble) + length
d = [tobinary(l), ]
d.extend(preamble)
s = "".join(d)
self.start_send(s)
self.start_send(block)
return
LOG.debug("> PIECE %d %d len=%d" % (index, begin, len(block)))
self._send_message(struct.pack("!cII%ss" % len(block), PIECE,
index, begin, block))