本文整理汇总了Python中twisted.python.log.debug函数的典型用法代码示例。如果您正苦于以下问题:Python debug函数的具体用法?Python debug怎么用?Python debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了debug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: succeed
def succeed(*args, **kwargs):
log.debug("ClientQueue: success, queue size %d, reqs out %d" % (len(self.queue), self.count))
self.count -= 1
try:
success(*args, **kwargs)
except Exception, e:
log.err("Exception '%s' in ClientQueue callback; moving on" % str(e))
示例2: preApplication
def preApplication(self):
"""
We don't actually want to override this method since there is nothing
interesting to do in here.
"""
log.debug("[D] %s %s " % (__file__, __name__), "Class GLBaseRunner", "preApplication")
pass
示例3: dispatch
def dispatch(self, msg):
# Get the artifact signature id
match = self.regex.search(msg)
if not match:
log.debug('Failed to match snort rule-signature in msg: {!r}'.format(msg))
return msg
sig = match.group('sig')
# Check if traffic dump should be generated
dump = False
if self.conf.traffic_dump.match_exclude:
for regex in self.conf.traffic_dump.match_exclude:
if re.search(regex, msg):
dump = None
break
if dump is not None:
if sig in self.conf.traffic_dump.signatures: dump = True
if not dump and self.conf.traffic_dump.match:
for regex in self.conf.traffic_dump.match:
if re.search(regex, msg):
dump = True
break
if dump:
try: dump = self.traffic_dump()
except Exception as err:
msg += '\n dump failed: {}'.format(err)
else: msg += '\n dump: {}'.format(dump)
return msg
示例4: dispatch
def dispatch(self, msg):
for pat, pat_re in self.patterns.viewitems():
if pat_re.search(msg):
log.debug("Matched nflog-dump pattern: {}".format(pat))
break
else:
return
ts = time()
if self.conf.traffic_dump.min_interval and self.last_dump > ts - self.conf.traffic_dump.min_interval:
log.debug(
"Ignoring nflog-dump pattern match"
" ({}) due to rate-limiting (elapsed: {:.1f}, min: {})".format(
pat, ts - self.last_dump, self.conf.traffic_dump.min_interval
)
)
return
self.last_dump = ts
msg = "Matched nflog-dump pattern: {}".format(pat)
try:
dump = self.traffic_dump(ts=ts)
except Exception as err:
msg += "\n dump failed: {}".format(err)
else:
msg += "\n dump: {}".format(dump)
return msg
示例5: __reduce
def __reduce(self):
"""Pull stuff off the queue."""
#only need to reduce if there is more than one item in the queue
if len(self.queue) == 1:
#if we've received all the results from all the shards
#and the queue only has 1 element in it, then we're done reducing
if self.num_entries_remaining == 0 and self.reduces_out == 0:
# if this was a count query, slice stuff off
if self.count is not None:
log.debug("count: %d, skip: %d, results: %d" % (self.count, self.skip, len(self.queue[0]['rows'])))
self.queue[0]['rows'] = self.queue[0]['rows'][self.skip:self.skip+self.count]
elif self.skip > 0:
self.queue[0]['rows'] = self.queue[0]['rows'][self.skip:]
body = cjson.encode(self.queue[0])
# filter headers that should not be reverse proxied
strip_headers = ['content-length', 'etag']
headers = dict([(k,v) for k,v in self.headersrecvd.iteritems() if k.lower() not in strip_headers])
# calculate a deterministic etag
nodes = self.etags.keys()
nodes.sort() # sum in deterministic order
md5etag = md5.md5()
for node in nodes:
md5etag.update(self.etags[node])
if len(nodes) > 0:
headers['etag'] = ['"%s"' % md5etag.hexdigest()]
log.debug("Reducer: response headers = %s" % str(headers))
self.reduce_deferred.callback((self.coderecvd, headers, body))
return
a,b = self.queue[:2]
self.queue = self.queue[2:]
# hand the work off to _do_reduce, which we can override
self._do_reduce(a,b)
示例6: dispatch
def dispatch(self, msg):
match = self.regex.search(msg)
if not match:
log.debug('Failed to match snort rule-sid in msg: {!r}'.format(msg))
return msg
sid = match.group('sid')
if self.gid_ignore:
try: gid = match.group('gid')
except IndexError: pass
else:
if gid in self.gid_ignore: return msg
ts = time()
if self.sid_db_ts < ts - self.conf.sid_db_mtime_check_interval:
if not os.path.exists(self.conf.paths.sid_db)\
or max(0, *( os.stat(p).st_mtime
for p in [self.conf.paths.sid_src, self.conf.paths.refs]
if os.path.exists(p) )) > os.stat(self.conf.paths.sid_db).st_mtime:
self.update_sid_db()
self.sid_db = anydbm.open(self.conf.paths.sid_db)
try: ref = force_unicode(self.sid_db[force_bytes(sid)])
except KeyError:
log.info('Failed to find refs for sid: {!r} (msg: {!r})'.format(sid, msg))
else: msg += u'\n refs: {}'.format(ref)
return msg
示例7: socks_method_CONNECT
def socks_method_CONNECT (self):
# Check if we have ip address or domain name
#
log.debug("socks_method_CONNECT host = " + self.host)
# The FaceTime SOCKS5 proxy treats IP addr the same way as hostname
# if _ip_regex.match (self.host):
# # we have dotted quad IP address
# addressType = 1
# address = socket.inet_aton (self.host)
# else:
# # we have host name
# address = self.host
# addressType = 3
address = self.host
addressType = 3
addressLen = len(address)
#Protocol version=5, Command=1 (CONNECT), Reserved=0
#command = struct.pack ("!BBBB", 5, 1, 0, addressType)
command = struct.pack ("!BBBBB", 5, 1, 0, addressType,addressLen)
portstr = struct.pack ("!H", self.port)
self.transport.write (command + address + portstr)
self.state = "gotConnectReply"
示例8: socks_gotHelloReply
def socks_gotHelloReply (self, data):
""" Receive server greeting and send authentication or ask to
execute requested method right now.
"""
if data == "\x05\xFF":
# No acceptable methods. We MUST close
#
log.debug("No acceptable methods, closing connection")
self.transport.loseConnection()
return
elif data == "\x05\x00":
# Anonymous access allowed - let's issue connect
#
self.sendCurrentMethod()
elif data == "\x05\x02":
# Authentication required
#
self.sendAuth()
else:
self.transport.loseConnection()
self.factory.clientConnectionFailed (self, failure.Failure (
UnhandledData ("Server returned unknown reply in gotHelloReply")))
# From now on SOCKS server considered alive - we've got reply
#
self.factory.status = "connected"
示例9: answer
def answer(self, transport, recipient, message):
user = self.auth.authenticate(recipient)
if user:
session = USSDSession.objects.recent(user)
if session:
log.debug("User: %s USSD Session: %s" % (user, session))
msg = str(message)
if msg == "$start":
response = handle_start(session)
elif msg == "$end":
response = handle_end(session)
elif msg == "$error":
import pdb
pdb.set_trace()
else:
if session.current_menu and not session.current_menu.is_finished():
response = handle_session(session, msg)
else:
response = "Use $start to create menu"
if recipient and response:
transport(recipient, response)
else:
log.error("Either recipient (%s) or response (%s) is not valid!" % (recipient, response))
return
else:
transport(recipient, "Error: No USSD Session!")
else:
transport(recipient, "Error: No User!")
示例10: run
def run(self):
log.debug('[Task] running')
self._running = True
self._aborted = False
o = (self.fnc, self.args, self.kwargs, self.onComplete)
fnc_queue.put(o)
示例11: dataReceived
def dataReceived(self, recd):
self.recvd = self.recvd + recd
while len(self.recvd) >= 10:
# hack for DeLorme EarthMate
if self.recvd[:8] == 'EARTHA\r\n':
if self.allow_earthmate_hack:
self.allow_earthmate_hack = 0
self.transport.write('EARTHA\r\n')
self.recvd = self.recvd[8:]
continue
if self.recvd[0:2] != '\xFF\x81':
if DEBUG:
raise ZodiacParseError('Invalid Sync %r' % self.recvd)
else:
raise ZodiacParseError
sync, msg_id, length, acknak, checksum = struct.unpack('<HHHHh', self.recvd[:10])
# verify checksum
cksum = -(reduce(operator.add, (sync, msg_id, length, acknak)) & 0xFFFF)
cksum, = struct.unpack('<h', struct.pack('<h', cksum))
if cksum != checksum:
if DEBUG:
raise ZodiacParseError('Invalid Header Checksum %r != %r %r' % (checksum, cksum, self.recvd[:8]))
else:
raise ZodiacParseError
# length was in words, now it's bytes
length = length * 2
# do we need more data ?
neededBytes = 10
if length:
neededBytes += length + 2
if len(self.recvd) < neededBytes:
break
if neededBytes > self.MAX_LENGTH:
raise ZodiacParseError("Invalid Header??")
# empty messages pass empty strings
message = ''
# does this message have data ?
if length:
message, checksum = self.recvd[10:10+length], struct.unpack('<h', self.recvd[10+length:neededBytes])[0]
cksum = 0x10000 - (reduce(operator.add, struct.unpack('<%dH' % (length/2), message)) & 0xFFFF)
cksum, = struct.unpack('<h', struct.pack('<h', cksum))
if cksum != checksum:
if DEBUG:
log.debug('msg_id = %r length = %r' % (msg_id, length))
raise ZodiacParseError('Invalid Data Checksum %r != %r %r' % (checksum, cksum, message))
else:
raise ZodiacParseError
# discard used buffer, dispatch message
self.recvd = self.recvd[neededBytes:]
self.receivedMessage(msg_id, message, acknak)
示例12: fail
def fail(*args, **kwargs):
log.debug("ClientQueue: failure, queue size %d, reqs out %d" % (len(self.queue), self.count))
self.count -= 1
try:
err(*args, **kwargs)
except:
log.err("Exception in ClientQueue errback; moving on")
self.next()
示例13: twisted_log
def twisted_log(eventDict):
log = logging.getLogger('twisted')
if 'failure' in eventDict:
log.error(eventDict.get('why') or 'Unhandled exception' + '\n' + str(eventDict['failure'].getTraceback()))
elif 'warning' in eventDict:
log.warning(eventDict['warning'])
else:
log.debug(' '.join([str(m) for m in eventDict['message']]))
示例14: _sendResponse
def _sendResponse(self, data, request, requestID, error=''):
response = json.dumps(
{'request': request, 'requestID': requestID,
'data': data,
'error': error}
)
log.debug('Sending response: %s' % response)
self.sendString(response)
示例15: inform
def inform():
if len(obs.orderbook.bids) > 0:
try:
print("Highest bid {:.2f}, lowest ask {:.2f}; lowest bid {:.2f} and highest ask {:.2f}.".format(
obs.highestbid, obs.lowestask, obs.orderbook.bids[-1].price, obs.orderbook.asks[-1].price))
pass
except TypeError as e:
log.debug("Error: {0}".format(e.message))