本文整理汇总了Python中dtella.common.log.LOG类的典型用法代码示例。如果您正苦于以下问题:Python LOG类的具体用法?Python LOG怎么用?Python LOG使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LOG类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setNetworkBan
def setNetworkBan(self, cidr, on_off):
# See if this is a valid 1.2.3.4/5 CIDR string.
try:
ipmask = ipv4.CidrStringToIPMask(cidr)
except ValueError, e:
LOG.error("Bad CIDR string: %s")
return
示例2: connectionMade
def connectionMade(self):
scfg = getServiceConfig()
LOG.info("Connected to IRC server.")
self.challenge = make_challenge()
my_capabs = [
("NICKMAX", 32),
("HALFOP", 1),
("CHANMAX", 65),
("MAXMODES", 20),
("IDENTMAX", 12),
("MAXQUIT", 255),
("MAXTOPIC", 307),
("MAXKICK", 255),
("MAXGECOS", 128),
("MAXAWAY", 200),
("IP6SUPPORT", 1),
("PROTOCOL", 1201),
("CHALLENGE", self.challenge),
]
my_capabs_str = ' '.join("%s=%s" % x for x in my_capabs)
self.sendLine("CAPAB START")
self.sendLine("CAPAB CAPABILITIES :%s" % my_capabs_str)
self.sendLine("CAPAB END")
示例3: connectionLost
def connectionLost(self, result):
LOG.info("Lost IRC connection.")
if self.ism.syncd:
self.ism.removeMeFromMain()
if self.shutdown_deferred:
self.shutdown_deferred.callback("Bye!")
示例4: checkIncomingNick
def checkIncomingNick(self, n):
# Validate new nicks as they join.
# If successful, return inick, else raise NickError.
try:
inick = dc_to_irc(n.nick)
if inick.lower() == self.bot_user.inick.lower():
raise NickError("Nick '%s' conflicts with IRC bot." % inick)
for q, reason in self.qlines.itervalues():
if q.match(inick):
raise NickError(
"Nick '%s' is Q-lined: %s" % (inick, reason))
except NickError, e:
LOG.debug("Bad nick: %s %s" % (n.nick, str(e)))
# Bad nick. KICK!
osm = self.main.osm
chunks = []
osm.bsm.addKickChunk(
chunks, n, cfg.irc_to_dc_bot, str(e),
rejoin=False, silent=True)
osm.bsm.sendBridgeChange(chunks)
raise
示例5: lineReceived
def lineReceived(self, line):
if not line:
return
if self.showirc:
LOG.log(5, ">: %s" % line)
if line[0] == ':':
try:
prefix, line = line[1:].split(' ', 1)
except ValueError:
return
else:
prefix = ''
try:
line, trailing = line.split(' :', 1)
except ValueError:
args = line.split()
else:
args = line.split()
args.append(trailing)
try:
f = getattr(self, 'handleCmd_%s' % args[0].upper())
except AttributeError:
pass
else:
f(prefix, args[1:])
示例6: handleCmd_KILL
def handleCmd_KILL(self, prefix, args):
l33t = prefix
n00b = args[0]
reason = irc_strip(args[1])
# In most cases, n00b is a UUID, but Anope seems to still use a nick.
# Thus, we have to try both everywhere :-/
# Reconnect the bot if it's killed.
if self.ism.isMyBot(n00b):
if self.ism.syncd:
self.pushBotJoin(do_nick=True)
return
l33t = self.ism.findUser(l33t).inick
# If n00b is a Dtella node, kick 'em.
n = self.ism.findDtellaNode(inick=n00b)
if n:
self.ism.kickDtellaNode(
n, l33t, "KILL: " + reason, send_quit=False)
return
# If n00b is an IRC user, treat it like a QUIT.
try:
n00b_u = self.ism.findUser(n00b)
except KeyError:
LOG.warning("Tried to KILL unknown user: %s" % n00b)
return
message = (
"%s has KILL'd %s: %s" %
(irc_to_dc(l33t), irc_to_dc(n00b_u.inick), reason))
self.ism.removeUser(n00b_u, message)
示例7: handleCmd_PING
def handleCmd_PING(self, prefix, args):
LOG.info("PING? PONG!")
scfg = getServiceConfig()
if len(args) == 1:
self.sendLine("PONG %s :%s" % (scfg.my_host, args[0]))
elif len(args) == 2:
self.sendLine("PONG %s :%s" % (args[1], args[0]))
示例8: handleCmd_TKL
def handleCmd_TKL(self, prefix, args):
addrem = args[0]
kind = args[1]
if addrem == '+':
on_off = True
elif addrem == '-':
on_off = False
else:
LOG.error("TKL: invalid modifier: '%s'" % addrem)
return
# :irc1.dhirc.com TKL + Z * 128.10.12.0/24 [email protected] 0 1171427130 :no reason
if kind == 'Z' and args[2] == '*':
cidr = args[3]
self.ism.setNetworkBan(cidr, on_off)
# :%s TKL + Q * %s* %s 0 %d :Reserved for Dtella
elif kind == 'Q':
nickmask = args[3]
if on_off:
reason = args[-1]
self.ism.addQLine(nickmask, reason)
else:
self.ism.removeQLine(nickmask)
示例9: handleCmd_SERVER
def handleCmd_SERVER(self, prefix, args):
if prefix:
# Not from our connected server
return
if self.server_name:
# Could be a dupe? Ignore it.
return
# We got a reply from the our connected IRC server, so our password
# was just accepted. Send the Dtella state information into IRC.
# Save server name
CHECK(args[0])
self.server_name = args[0]
LOG.info("IRC Server Name: %s" % self.server_name)
# Tell the ReconnectingClientFactory that we're cool
self.factory.resetDelay()
# This isn't very correct, because the Dtella nicks
# haven't been sent yet, but it's the best we can practically do.
scfg = getServiceConfig()
cloak_checksum = scfg.hostmasker.getChecksum()
self.sendLine("NETINFO 0 %d 0 %s 0 0 0 :%s" %
(time.time(), cloak_checksum, scfg.network_name))
self.sendLine(":%s EOS" % scfg.my_host)
示例10: handleCmd_EOS
def handleCmd_EOS(self, prefix, args):
if prefix != self.server_name:
return
if self.ism.syncd:
return
LOG.info("Finished receiving IRC sync data.")
self.showirc = True
# Check for conflicting bridges.
if self.ism.findConflictingBridge():
LOG.error("My nick prefix is in use! Terminating.")
self.transport.loseConnection()
reactor.stop()
return
# Set up nick reservation
scfg = getServiceConfig()
self.sendLine(
"TKL + Q * %s* %s 0 %d :Reserved for Dtella" %
(cfg.dc_to_irc_prefix, scfg.my_host, time.time()))
self.ism.killConflictingUsers()
# Send my own bridge nick
self.pushBotJoin(do_nick=True)
# When we enter the syncd state, register this instance with Dtella.
# This will eventually trigger event_DtellaUp, where we send our state.
self.schedulePing()
self.ism.addMeToMain()
示例11: handleCmd_QUIT
def handleCmd_QUIT(self, prefix, args):
uuid = prefix
try:
u = self.ism.findUser(uuid)
except KeyError:
LOG.warning("Can't quit user: %s" % uuid)
else:
self.ism.removeUser(u)
示例12: cleanupOnExit
def cleanupOnExit(self):
LOG.info("Reactor is shutting down. Doing cleanup.")
self.shutdown(reconnect='no')
self.state.saveState()
# Cleanly close the IRC connection before terminating
if self.ism:
return self.ism.shutdown()
示例13: killConflictingUsers
def killConflictingUsers(self):
# Find any reserved nicks, and KILL them.
CHECK(self.ircs and not self.syncd)
bad_users = [u for u in set(self.users.itervalues())
if matches_dc_to_irc_prefix(u.inick)]
LOG.info("Conflicting users: %r" % bad_users)
for u in bad_users:
self.ircs.event_KillUser(u)
self.removeUser(u)
示例14: runDconfigPusher
def runDconfigPusher():
import dtella.bridge_config as cfg
setLogFile(cfg.file_base + ".log", 4<<20, 4)
LOG.debug("Dconfig Pusher Logging Manager Initialized")
addTwistedErrorCatcher(LOG.critical)
from dtella.bridge.push_dconfig_main import DtellaMain_DconfigPusher
dtMain = DtellaMain_DconfigPusher()
reactor.run()
示例15: removeQLine
def removeQLine(self, nickmask):
self.qlines.pop(nickmask, None)
LOG.info("Removed Q-line: " + nickmask)
# If some other bridge removes our reservation, abort.
if self.syncd and (nickmask == cfg.dc_to_irc_prefix + "*"):
LOG.error("My own Q-line was removed! Terminating.")
if self.ircs:
self.ircs.transport.loseConnection()
reactor.stop()