diff --git a/src/conf.py b/src/conf.py index 07294f9e9..8c87dd636 100644 --- a/src/conf.py +++ b/src/conf.py @@ -114,14 +114,13 @@ supybot.register('channels', SpaceSeparatedListOfChannels(['#supybot'], """ Determines what channels the bot will join when it connects to the server.""")) class ValidPrefixChars(registry.String): - def set(self, s): - registry.String.set(self, s) - if self.value.translate(string.ascii, - '`~!@#$%^&*()_-+=[{}]\\|\'";:,<.>/?'): + def setValue(self, v): + if v.translate(string.ascii, '`~!@#$%^&*()_-+=[{}]\\|\'";:,<.>/?'): raise registry.InvalidRegistryValue, \ 'Value must contain only ~!@#$%^&*()_-+=[{}]\\|\'";:,<.>/?' + registry.String.setValue(self, v) -supybot.register('prefixChars', ValidPrefixChars('@', """Determines what prefix +supybot.register('prefixChars', ValidPrefixChars('', """Determines what prefix characters the bot will reply to. A prefix character is a single character that the bot will use to determine what messages are addressed to it; when there are no prefix characters set, it just uses its nick.""")) @@ -361,20 +360,12 @@ supybot.drivers.register('poll', registry.Float(1.0, """Determines the default length of time a driver should block waiting for input.""")) class ValidDriverModule(registry.String): - def set(self, s): - original = getattr(self, 'value', self.default) - registry.String.set(self, s) - if self.value not in ('socketDrivers', - 'twistedDrivers', - 'asyncoreDrivers'): - self.value = original + def setValue(self, v): + if v not in ('socketDrivers', 'twistedDrivers', 'asyncoreDrivers'): raise registry.InvalidRegistryValue, \ 'Value must be one of "socketDrivers", "asyncoreDrivers", ' \ 'or twistedDrivers.' - else: - # TODO: check to make sure Twisted is available if it's set to - # twistedDrivers. - pass + registry.String.setValue(self, v) supybot.drivers.register('module', ValidDriverModule('socketDrivers', """ Determines what driver module the bot will use. socketDrivers, a simple diff --git a/src/log.py b/src/log.py index fa7cbd1fe..66b005d41 100644 --- a/src/log.py +++ b/src/log.py @@ -36,7 +36,6 @@ import fix import os import sys import time -import cgitb import types import atexit import logging @@ -57,16 +56,7 @@ class Formatter(logging.Formatter): for exn in deadlyExceptions: if issubclass(e.__class__, exn): raise - if conf.supybot.log.detailedTracebacks(): - try: - # Cgitb has bugs, and they break the bot. - #return cgitb.text((E, e, tb)).rstrip('\r\n') - return logging.Formatter.formatException(self, (E, e, tb)) - except: - error('Cgitb.text raised an exception.') - return logging.Formatter.formatException(self, (E, e, tb)) - else: - return logging.Formatter.formatException(self, (E, e, tb)) + return logging.Formatter.formatException(self, (E, e, tb)) class BetterStreamHandler(logging.StreamHandler): @@ -198,15 +188,6 @@ conf.supybot.log.register('level', LogLevel(logging.INFO, """Determines what the minimum priority level logged will be. Valid values are DEBUG, INFO, WARNING, ERROR, and CRITICAL, in order of increasing priority.""")) -conf.supybot.log.register('timestampFormat', -registry.String('[%d-%b-%Y %H:%M:%S]', -"""Determines the format string for timestamps in logfiles. Refer to the -Python documentation for the time module to see what formats are accepted.""")) -conf.supybot.log.register('detailedTracebacks', registry.Boolean(True, """ -Determines whether highly detailed tracebacks will be logged. While more -informative (and thus more useful for debugging) they also take a significantly -greater amount of space in the logs. Hopefully, however, such uncaught -exceptions aren't very common.""")) conf.supybot.log.register('stdout', registry.Boolean(True, """Determines whether the bot will log to stdout.""")) @@ -220,7 +201,11 @@ class BooleanRequiredFalseOnWindows(registry.Boolean): conf.supybot.log.stdout.register('colorized', BooleanRequiredFalseOnWindows(False, """Determines whether the bot's logs to stdout (if enabled) will be colorized with ANSI color.""")) - + +conf.supybot.log.register('timestampFormat', +registry.String('[%d-%b-%Y %H:%M:%S]', +"""Determines the format string for timestamps in logfiles. Refer to the +Python documentation for the time module to see what formats are accepted.""")) if not os.path.exists(conf.supybot.directories.log()): os.mkdir(conf.supybot.directories.log(), 0755) diff --git a/src/registry.py b/src/registry.py index a6529ce63..b772b1b7f 100644 --- a/src/registry.py +++ b/src/registry.py @@ -283,7 +283,7 @@ class String(Value): v = utils.safeEval(s) if not isinstance(v, basestring): raise ValueError - self.value = v + self.setValue(v) except ValueError: # This catches utils.safeEval(s) errors too. raise InvalidRegistryValue, '%r is not a string.' % s @@ -319,8 +319,9 @@ class Regexp(Value): try: if s: self.value = utils.perlReToPythonRe(s) + self._lastModified = time.time() else: - self.value = None + self.setValue(None) self.sr = s except ValueError, e: raise InvalidRegistryValue, '%r is not a valid regexp: %s' % (s, e) @@ -328,7 +329,7 @@ class Regexp(Value): def setValue(self, v): if v is None: self.sr = '' - self.value = None + Value.setValue(self, None) else: raise InvalidRegistryValue, \ 'Can\'t set to a regexp, there would be an inconsistency ' \