本文整理汇总了Python中mixminion.Common.LOG类的典型用法代码示例。如果您正苦于以下问题:Python LOG类的具体用法?Python LOG怎么用?Python LOG使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LOG类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: regenerateDescriptors
def regenerateDescriptors(self):
"""Regenerate all server descriptors for all keysets in this
keyring, but keep all old keys intact."""
LOG.info("Regenerating server descriptors; keeping old keys.")
identityKey = self.getIdentityKey()
for _,_,ks in self.keySets:
ks.regenerateServerDescriptor(self.config, identityKey)
示例2: checkDescriptorConsistency
def checkDescriptorConsistency(self, regen=1):
"""Check whether the server descriptors in this keyring are
consistent with the server's configuration. If 'regen' is
true, inconsistent descriptors are regenerated."""
identity = None
state = []
for _,_,ks in self.keySets:
ok = ks.checkConsistency(self.config, 0)
if ok == 'good':
continue
state.append((ok, ks))
if not state:
return
LOG.warn("Some generated keysets do not match "
"current configuration...")
for ok, ks in state:
va,vu = ks.getLiveness()
LOG.warn("Keyset %s (%s--%s):",ks.keyname,formatTime(va,1),
formatTime(vu,1))
ks.checkConsistency(self.config, 1)
if regen and ok == 'bad':
if not identity: identity = self.getIdentityKey()
ks.regenerateServerDescriptor(self.config, identity)
示例3: prevalidate
def prevalidate(self, contents):
for name, ents in contents:
if name == 'Server':
for k,v,_ in ents:
if k == 'Descriptor-Version' and v.strip() != '0.2':
raise ConfigError("Unrecognized descriptor version: %s"
% v.strip())
# Remove any sections with unrecognized versions.
revisedContents = []
for name, ents in contents:
v = self.expected_versions.get(name)
if not v:
revisedContents.append((name, ents))
continue
versionkey, versionval = v
for k,v,_ in ents:
if k == versionkey and v.strip() != versionval:
LOG.warn("Skipping %s section with unrecognized version %s"
, name, v.strip())
break
else:
revisedContents.append((name, ents))
return revisedContents
示例4: lookup
def lookup(self,name,cb):
"""Look up the name 'name', and pass the result to the callback
function 'cb' when we're done. The result will be of the
same form as the return value of NetUtils.getIP: either
(Family, Address, Time) or ('NOENT', Reason, Time).
Note: The callback may be invoked from a different thread. Either
this thread or a DNS thread will block until the callback finishes,
so it shouldn't be especially time-consuming.
"""
# Check for a static IP first; no need to resolve that.
v = mixminion.NetUtils.nameIsStaticIP(name)
if v is not None:
cb(name,v)
return
try:
self.lock.acquire()
v = self.cache.get(name)
# If we don't have a cached answer, add cb to self.callbacks
if v is None or v is PENDING:
self.callbacks.setdefault(name, []).append(cb)
# If we aren't looking up the answer, start looking it up.
if v is None:
LOG.trace("DNS cache starting lookup of %r", name)
self._beginLookup(name)
finally:
self.lock.release()
# If we _did_ have an answer, invoke the callback now.
if v is not None and v is not PENDING:
LOG.trace("DNS cache returning cached value %s for %r",
v,name)
cb(name,v)
示例5: _validateZlib
def _validateZlib():
"""Internal function: Make sure that zlib is a recognized version, and
that it compresses things as expected. (This check is important,
because using a zlib version that compressed differently from zlib1.1.4
would make senders partitionable by payload compression.)
"""
global _ZLIB_LIBRARY_OK
ver = getattr(zlib, "ZLIB_VERSION", None)
if ver and ver < "1.1.2":
raise MixFatalError("Zlib version %s is not supported"%ver)
_ZLIB_LIBRARY_OK = 0.5
if ver in ("1.1.2", "1.1.3", "1.1.4", "1.2.0", "1.2.0.1", "1.2.0.2",
"1.2.0.3", "1.2.0.4", "1.2.0.5", "1.2.0.6", "1.2.0.7",
"1.2.0.8", "1.2.1", "1.2.1.1", "1.2.1.2", "1.2.2", "1.2.2.2",
"1.2.3", "1.2.7", "1.2.8"):
_ZLIB_LIBRARY_OK = 1
return
LOG.info("Unrecognized zlib version: %r. Spot-checking output", ver)
# This test is inadequate, but it _might_ catch future incompatible
# changes.
_ZLIB_LIBRARY_OK = 0.5
good = '\x78\xda\xed\xc6A\x11\x00 \x08\x00\xb0l\xd4\xf0\x87\x02\xf6o'+\
'`\x0e\xef\xb6\xd7r\xed\x88S=7\xcd\xcc\xcc\xcc\xcc\xcc\xcc'+\
'\xcc\xcc\xcc\xcc\xcc\xcc\xcc\xcc\xcc\xcc\xcc\xcc\xbe\xdd\x03'+\
'q\x8d\n\x93'
if compressData("aZbAAcdefg"*1000) == good:
_ZLIB_LIBRARY_OK = 1
else:
_ZLIB_LIBRARY_OK = 0
raise MixFatalError("Zlib output not as exected.")
示例6: readProtocol
def readProtocol(self):
s = self.getInbufLine(4096,clear=1)
if s is None:
return
elif s == -1:
self.startShutdown()
#failed
return
self.stopReading()
m = PROTOCOL_RE.match(s)
if not m:
LOG.warn("Bad MMTP protocol string format from %s", self.address)
#failed
self.startShutdown()
return
protocols = m.group(1).split(",")
for p in self.PROTOCOL_VERSIONS:
if p in protocols:
self.protocol = p
self.onWrite = self.protocolWritten
self.beginWriting("MMTP %s\r\n"%p)
return
LOG.warn("No common protocols with %s", self.address)
#failed
self.startShutdown()
示例7: addChunk
def addChunk(self, h, fm):
"""Register a chunk with handle h and FragmentMetadata fm. If the
chunk is inconsistent with other fragments of this message,
raise MismatchedFragment."""
assert fm.isChunk
assert fm.messageid == self.messageid
if fm.size != self.params.length:
raise MismatchedFragment("Mismatched message length")
if fm.overhead != self.overhead:
raise MismatchedFragment("Mismatched packet overhead")
if self.chunks.has_key(fm.chunkNum):
raise MismatchedFragment("Duplicate chunks")
if fm.nym != self.nym:
raise MismatchedFragment("Fragments received for differing identities")
if self.inserted > fm.insertedDate:
self.inserted = fm.insertedDate
self.chunks[fm.chunkNum] = (h,fm)
if self.fragmentsByChunk[fm.chunkNum]:
LOG.warn("Found a chunk with unneeded fragments for message %r",
self.messageid)
if self.readyChunks.get(fm.chunkNum):
del self.readyChunks[fm.chunkNum]
示例8: processMessage
def processMessage(self, packet):
assert packet.getExitType() == 0xFFFE
exitInfo = packet.getAddress()
if exitInfo == 'fail':
return DELIVER_FAIL_RETRY
elif exitInfo == 'FAIL!':
return DELIVER_FAIL_NORETRY
LOG.debug("Delivering test message")
m = _escapeMessageForEmail(packet)
if m is None:
# Ordinarily, we'd drop corrupt messages, but this module is
# meant for debugging.
m = """\
==========CORRUPT OR UNDECODABLE MESSAGE
Decoding handle: %s%s==========MESSAGE ENDS""" % (
base64.encodestring(packet.getTag()),
base64.encodestring(packet.getContents()))
f = open(os.path.join(self.loc, str(self.next)), 'w')
self.next += 1
f.write(m)
f.close()
return DELIVER_OK
示例9: getSigners
def getSigners(self):
#DOCDOC -- returns members of self.dirInfo.voters with valid signatures.
if self.signers is not None:
return self.signers
sigs = {}
self.signers = []
for s in self.signatures:
sigs[s.getKeyFingerprint()] = s
for digest, url in self.dirInfo.voters:
try:
s = sigs[digest]
except KeyError:
#XXXX008 log something.
continue
if s.checkSignature():
LOG.trace("Found valid signature from %s at %s",
digest, url)
self.signers.append((digest, url))
else:
LOG.trace("Signature claiming to be from %s was not valid",
digest)
continue
return self.signers
示例10: sendPackets
def sendPackets(routing, packetList, timeout=300, callback=None):
"""Sends a list of packets to a server. Raise MixProtocolError on
failure.
routing -- an instance of mixminion.Packet.IPV4Info or
mixminion.Packet.MMTPHostInfo.
If routing.keyinfo == '\000'*20, we ignore the server's
keyid.
packetList -- a list of 32KB packets and control strings. Control
strings must be one of "JUNK" to send a 32KB padding chunk,
or "RENEGOTIATE" to renegotiate the connection key.
connectTimeout -- None, or a number of seconds to wait for data
on the connection before raising TimeoutError.
callback -- None, or a function to call with a index into packetList
after each successful packet delivery.
"""
# Find out where we're connecting to.
serverName = mixminion.ServerInfo.displayServerByRouting(routing)
if isinstance(routing, IPV4Info):
family, addr = socket.AF_INET, routing.ip
else:
assert isinstance(routing, MMTPHostInfo)
LOG.trace("Looking up %s...",routing.hostname)
family, addr, _ = mixminion.NetUtils.getIP(routing.hostname)
if family == "NOENT":
raise MixProtocolError("Couldn't resolve hostname %s: %s" % (
routing.hostname, addr))
# Create an MMTPClientConnection
try:
con = MMTPClientConnection(
family, addr, routing.port, routing.keyinfo, serverName=serverName)
except socket.error, e:
raise MixProtocolError(str(e))
示例11: __readTooMuch
def __readTooMuch(self):
"""Helper function -- called if we read too much data while we're
shutting down."""
LOG.error("Read over 128 bytes of unexpected data from closing "
"connection to %s", self.address)
self.onTLSError()
raise _Closing()
示例12: run
def run(self):
"""Thread body: pull questions from the DNS thread queue and
answer them."""
queue = self.dnscache.queue
_lookupDone = self.dnscache._lookupDone
_adjBusyThreads = self.dnscache._adjBusyThreads
_adjLiveThreads = self.dnscache._adjLiveThreads
try:
_adjLiveThreads(1)
try:
while 1:
# Get a question from the queue, but don't wait more than
# MAX_THREAD_IDLE seconds
hostname = queue.get(timeout=MAX_THREAD_IDLE)
# If the question is None, shutdown.
if hostname is None:
return
# Else, resolve the IP and send the answer to the dnscache
_adjBusyThreads(1)
result = mixminion.NetUtils.getIP(hostname)
_lookupDone(hostname, result)
_adjBusyThreads(-1)
except QueueEmpty:
LOG.debug("DNS thread shutting down: idle for %s seconds.",
MAX_THREAD_IDLE)
except:
LOG.error_exc(sys.exc_info(),
"Exception in DNS thread; shutting down.")
finally:
_adjLiveThreads(-1)
示例13: getHeaders
def getHeaders(self):
"""Return a dict containing the headers for this message."""
if self.type is None:
self.decode()
if self.headers is None:
LOG.warn("getHeaders found no decoded headers")
return {}
return self.headers
示例14: __clientFinished
def __clientFinished(self, addr):
"""Called when a client connection runs out of packets to send,
or halts."""
try:
del self.clientConByAddr[addr]
except KeyError:
LOG.warn("Didn't find client connection to %s in address map",
addr)
示例15: process
def process(self, r, w, x, cap):
#XXXX007 do something with x
try:
con, addr = self.sock.accept()
LOG.debug("Accepted connection from %s", addr)
self.connectionFactory(con)
except socket.error, e:
LOG.warn("Socket error while accepting connection: %s", e)