Changed debug.debugMsg to debug.msg.

This commit is contained in:
Jeremy Fincher 2003-04-03 10:06:11 +00:00
parent e88a5a3ae0
commit 33b4aa052c
8 changed files with 29 additions and 30 deletions

View File

@ -140,7 +140,7 @@ class MiscCommands(callbacks.Privmsg):
will be logged, so don't abuse this command or you'll have an upset will be logged, so don't abuse this command or you'll have an upset
admin to deal with. admin to deal with.
""" """
debug.debugMsg(pprint.pformat(irc.state.history), 'normal') debug.msg(pprint.pformat(irc.state.history), 'normal')
irc.reply(msg, conf.replySuccess) irc.reply(msg, conf.replySuccess)
def version(self, irc, msg, args): def version(self, irc, msg, args):

View File

@ -78,7 +78,7 @@ class AsyncoreDriver(asynchat.async_chat, object):
if self.reconnect: if self.reconnect:
when = time.time() + 60 when = time.time() + 60
whenS = time.strftime(conf.timestampFormat, time.localtime(when)) whenS = time.strftime(conf.timestampFormat, time.localtime(when))
debug.debugMsg('Scheduling reconnect at %s' % whenS, 'normal') debug.msg('Scheduling reconnect at %s' % whenS, 'normal')
def makeNewDriver(): def makeNewDriver():
self.irc.reset() self.irc.reset()
driver = self.__class__(self.server, reconnect=self.reconnect) driver = self.__class__(self.server, reconnect=self.reconnect)
@ -145,7 +145,7 @@ class ReplListener(asyncore.dispatcher, object):
def handle_accept(self): def handle_accept(self):
(sock, addr) = self.accept() (sock, addr) = self.accept()
debug.debugMsg('Connection made to telnet-REPL: ' + str(addr),'normal') debug.msg('Connection made to telnet-REPL: ' + str(addr),'normal')
Repl((sock, addr)) Repl((sock, addr))
@ -195,7 +195,7 @@ Name: """ % (world.version, sys.version.translate(string.ascii, '\r\n'))
self.tries += 1 self.tries += 1
self.prompt = 'Name: ' self.prompt = 'Name: '
msg = 'Unknown user %s on telnet REPL.' % name msg = 'Unknown user %s on telnet REPL.' % name
debug.debugMsg(msg,'high') debug.msg(msg,'high')
self.push(self.prompt) self.push(self.prompt)
elif self.u is not None and not self.authed: elif self.u is not None and not self.authed:
password = self.buffer password = self.buffer
@ -208,16 +208,16 @@ Name: """ % (world.version, sys.version.translate(string.ascii, '\r\n'))
self.push('Only owners can use this feature.\n') self.push('Only owners can use this feature.\n')
self.close() self.close()
msg = 'Attempted non-owner user %s on telnet REPL' % name msg = 'Attempted non-owner user %s on telnet REPL' % name
debug.debugMsg(msg, 'high') debug.msg(msg, 'high')
else: else:
self.push('Incorrect Password.\n') self.push('Incorrect Password.\n')
self.prompt = 'Name: ' self.prompt = 'Name: '
self.u = None self.u = None
msg = 'Invalid password for user %s on telnet REPL.' % name msg = 'Invalid password for user %s on telnet REPL.' % name
debug.debugMsg(msg, 'high') debug.msg(msg, 'high')
self.push(self.prompt) self.push(self.prompt)
elif self.authed: elif self.authed:
debug.debugMsg('Telnet REPL: %s' % self.buffer) debug.msg('Telnet REPL: %s' % self.buffer)
ret = self.repl.addLine(self.buffer+'\r\n') ret = self.repl.addLine(self.buffer+'\r\n')
self.buffer = '' self.buffer = ''
if ret is not repl.NotYet: if ret is not repl.NotYet:

View File

@ -236,15 +236,15 @@ class IrcObjectProxy:
if callback is not None: if callback is not None:
anticap = ircdb.makeAntiCapability(name) anticap = ircdb.makeAntiCapability(name)
if ircdb.checkCapability(self.msg.prefix, anticap): if ircdb.checkCapability(self.msg.prefix, anticap):
debug.debugMsg('Preventing %s from calling %s' % \ debug.msg('Preventing %s from calling %s' % \
(self.msg.nick, name)) (self.msg.nick, name))
return return
recipient = self.msg.args[0] recipient = self.msg.args[0]
if ircutils.isChannel(recipient): if ircutils.isChannel(recipient):
chancap = ircdb.makeChannelCapability(recipient, anticap) chancap = ircdb.makeChannelCapability(recipient, anticap)
if ircdb.checkCapability(self.msg.prefix, chancap): if ircdb.checkCapability(self.msg.prefix, chancap):
debug.debugMsg('Preventing %s from calling %s' % \ debug.msg('Preventing %s from calling %s' % \
(self.msg.nick, name)) (self.msg.nick, name))
return return
command = getattr(callback, name) command = getattr(callback, name)
callback.callCommand(command, self, self.msg, self.args) callback.callCommand(command, self, self.msg, self.args)
@ -418,7 +418,7 @@ class PrivmsgRegexp(Privmsg):
s = '%s.%s has an invalid regexp %s: %s' % \ s = '%s.%s has an invalid regexp %s: %s' % \
(self.__class__.__name__, name, (self.__class__.__name__, name,
value.__doc__, debug.exnToString(e)) value.__doc__, debug.exnToString(e))
debug.debugMsg(s) debug.msg(s)
def doPrivmsg(self, irc, msg): def doPrivmsg(self, irc, msg):
for (r, method) in self.res: for (r, method) in self.res:

View File

@ -136,7 +136,7 @@ def recoverableException():
raise raise
lastTimes.append(time.time()) lastTimes.append(time.time())
if lastTimes[-1] - lastTimes[0] < 0.20: if lastTimes[-1] - lastTimes[0] < 0.20:
debugMsg('Too many exceptions too quickly. Bailing out.', 'high') msg('Too many exceptions too quickly. Bailing out.', 'high')
exit() exit()
else: else:
del lastTimes[0] del lastTimes[0]
@ -160,15 +160,15 @@ def unrecoverableException():
recoverableException() recoverableException()
exit(-1) exit(-1)
def debugMsg(msg, priority='low'): def msg(s, priority='low'):
if priorities[priority] >= priorities[minimumDebugPriority]: if priorities[priority] >= priorities[minimumDebugPriority]:
if stderr: if stderr:
if colorterm: if colorterm:
sys.stderr.write(priorityColors.get(priority)) sys.stderr.write(priorityColors.get(priority))
_writeNewline(sys.stderr, msg) _writeNewline(sys.stderr, s)
if colorterm: if colorterm:
sys.stderr.write(ansi.RESET) sys.stderr.write(ansi.RESET)
_writeNewline(_debugfd, msg) _writeNewline(_debugfd, s)
_debugfd.flush() _debugfd.flush()
def printf(msg): def printf(msg):

View File

@ -426,7 +426,7 @@ def checkCapability(hostmask, capability, users=users, channels=channels):
try: try:
(channel, capability) = fromChannelCapability(capability) (channel, capability) = fromChannelCapability(capability)
except ValueError: # unpack list of wrong size except ValueError: # unpack list of wrong size
debug.debugMsg('Invalid channel capability in checkCapability') debug.msg('Invalid channel capability in checkCapability')
return False # stupid, invalid capability. return False # stupid, invalid capability.
# Now, go fetch the channel and check to see what it thinks about # Now, go fetch the channel and check to see what it thinks about
# said capability. # said capability.
@ -457,7 +457,7 @@ def checkCapability(hostmask, capability, users=users, channels=channels):
try: try:
(channel, capability) = fromChannelCapability(capability) (channel, capability) = fromChannelCapability(capability)
except ValueError: except ValueError:
debug.debugMsg('Invalid channel capability in checkCapability') debug.msg('Invalid channel capability in checkCapability')
return False # stupid, invalid capability. return False # stupid, invalid capability.
c = channels.getChannel(channel) c = channels.getChannel(channel)
# And return the channel's opinion. # And return the channel's opinion.

View File

@ -77,7 +77,7 @@ class IrcCallback(object):
debug.recoverableException() debug.recoverableException()
s = 'Exception raised by %s.%s' % \ s = 'Exception raised by %s.%s' % \
(self.__class__.__name__, method.im_func.func_name) (self.__class__.__name__, method.im_func.func_name)
debug.debugMsg(s) debug.msg(s)
def reset(self): def reset(self):
pass pass
@ -105,7 +105,7 @@ class IrcMsgQueue(object):
def enqueue(self, msg): def enqueue(self, msg):
if msg in self.msgs: if msg in self.msgs:
if not world.startup: if not world.startup:
debug.debugMsg('Not adding msg %s to queue' % msg, 'normal') debug.msg('Not adding msg %s to queue' % msg, 'normal')
else: else:
self.msgs.add(msg) self.msgs.add(msg)
if msg.command in ('MODE', 'KICK', 'PONG'): if msg.command in ('MODE', 'KICK', 'PONG'):
@ -326,7 +326,7 @@ class Irc(object):
msg = self.fastqueue.dequeue() msg = self.fastqueue.dequeue()
elif self.queue: elif self.queue:
if now - self.lastTake <= conf.throttleTime: if now - self.lastTake <= conf.throttleTime:
debug.debugMsg('Irc.takeMsg throttling.', 'verbose') debug.msg('Irc.takeMsg throttling.', 'verbose')
else: else:
self.lastTake = now self.lastTake = now
msg = self.queue.dequeue() msg = self.queue.dequeue()
@ -337,7 +337,7 @@ class Irc(object):
self.driver.die() self.driver.die()
elif now > (self.lastping + conf.pingInterval): elif now > (self.lastping + conf.pingInterval):
if now - self.lastTake <= conf.throttleTime: if now - self.lastTake <= conf.throttleTime:
debug.debugMsg('Irc.takeMsg throttling.', 'verbose') debug.msg('Irc.takeMsg throttling.', 'verbose')
else: else:
self.lastping = now self.lastping = now
msg = ircmsgs.ping(str(int(now))) msg = ircmsgs.ping(str(int(now)))
@ -347,11 +347,11 @@ class Irc(object):
msg = callback.outFilter(self, msg) msg = callback.outFilter(self, msg)
if msg is None: if msg is None:
s = 'outFilter %s returned None' % callback.name() s = 'outFilter %s returned None' % callback.name()
debug.debugMsg(s) debug.msg(s)
return None return None
self.state.addMsg(self,ircmsgs.IrcMsg(msg=msg, prefix=self.prefix)) self.state.addMsg(self,ircmsgs.IrcMsg(msg=msg, prefix=self.prefix))
s = '%s %s' % (time.strftime(conf.timestampFormat), msg) s = '%s %s' % (time.strftime(conf.timestampFormat), msg)
debug.debugMsg(s, 'low') debug.msg(s, 'low')
if msg.command == 'NICK': if msg.command == 'NICK':
# We don't want a race condition where the server's NICK # We don't want a race condition where the server's NICK
# back to us is lost and someone else steals our nick and uses # back to us is lost and someone else steals our nick and uses
@ -365,8 +365,7 @@ class Irc(object):
return None return None
def feedMsg(self, msg): def feedMsg(self, msg):
debug.debugMsg('%s %s' % (time.strftime(conf.timestampFormat), msg), debug.msg('%s %s' % (time.strftime(conf.timestampFormat), msg), 'low')
'low')
# First, make sure self.nick is always consistent with the server. # First, make sure self.nick is always consistent with the server.
if msg.command == 'NICK' and msg.nick == self.nick: if msg.command == 'NICK' and msg.nick == self.nick:
if ircdb.users.hasUser(self.nick): if ircdb.users.hasUser(self.nick):
@ -418,7 +417,7 @@ class Irc(object):
m = callback.inFilter(self, msg) m = callback.inFilter(self, msg)
if not m: if not m:
debugmsg = 'inFilter %s returned None' % callback.name() debugmsg = 'inFilter %s returned None' % callback.name()
debug.debugMsg(debugmsg) debug.msg(debugmsg)
msg = m msg = m
except: except:
debug.recoverableException() debug.recoverableException()

View File

@ -80,7 +80,7 @@ class Repl(object):
line = line.rstrip() line = line.rstrip()
self.lines.append(line) self.lines.append(line)
if len(self.lines) > 100: if len(self.lines) > 100:
debug.debugMsg('too many lines in Repl.') debug.msg('too many lines in Repl.', 'normal')
self.lines = [] self.lines = []
return None return None
if line == '' or line == '\n' or line == '\r\n': if line == '' or line == '\n' or line == '\r\n':

View File

@ -83,11 +83,11 @@ def upkeep(): # Function to be run on occasion to do upkeep stuff.
if os.name == 'nt': if os.name == 'nt':
msvcrt.heapmin() msvcrt.heapmin()
if gc.garbage: if gc.garbage:
debug.debugMsg('Uncollectable garbge: %s' % gc.garbage, 'normal') debug.msg('Uncollectable garbge: %s' % gc.garbage, 'normal')
if 'noflush' not in tempvars: if 'noflush' not in tempvars:
flush() flush()
msg = '%s upkeep ran.' % time.strftime(conf.timestampFormat) msg = '%s upkeep ran.' % time.strftime(conf.timestampFormat)
debug.debugMsg(msg, 'verbose') debug.msg(msg, 'verbose')
''' '''
def superReload(oldmodule): def superReload(oldmodule):