Made the registry dynamically reloadable as well as added a supybot.flush configuration variable.

This commit is contained in:
Jeremy Fincher 2004-02-03 22:58:54 +00:00
parent 1df9b64c39
commit 4c8f3d5314
4 changed files with 18 additions and 4 deletions

View File

@ -249,6 +249,7 @@ if __name__ == '__main__':
if world.dying:
log.info('Finished writing registry file.')
world.flushers.append(closeRegistry)
world.registryFilename = registryFilename
nick = options.nick or conf.supybot.nick()
user = options.user or conf.supybot.user()

View File

@ -37,6 +37,7 @@ import getopt
import conf
import utils
import world
import ircdb
import plugins
import ircutils
@ -47,7 +48,6 @@ import callbacks
###
# Now, to setup the registry.
###
import registry
class InvalidRegistryName(callbacks.Error):
pass
@ -210,9 +210,9 @@ class Config(callbacks.Privmsg):
Reloads the various configuration files (user database, channel
database, registry, etc.).
"""
# TODO: Reload registry.
ircdb.users.reload()
ircdb.channels.reload()
registry.open(world.registryFilename)
irc.replySuccess()
reload = privmsgs.checkCapability(reload, 'owner')

View File

@ -352,6 +352,12 @@ supybot.register('pingInterval', registry.Integer(120, """Determines the
number of seconds between sending pings to the server, if pings are being sent
to the server."""))
supybot.register('flush', registry.Boolean(True, """Determines whether the bot
will periodically flush data and configuration files to disk. Generally, the
only time you'll want to set this to False is when you want to modify those
configuration files by hand and don't want the bot to flush its current version
over your modifications."""))
###
# Driver stuff.
###

View File

@ -66,6 +66,8 @@ ircs = [] # A list of all the IRCs.
flushers = [] # A periodic function will flush all these.
registryFilename = None
def flush():
"""Flushes all the registered flushers."""
for f in flushers:
@ -85,14 +87,19 @@ def upkeep():
pass
if gc.garbage:
log.warning('Uncollectable garbage: %s', gc.garbage)
if True: # XXX: Replace this with the registry variable.
flushed = conf.supybot.flush()
if flushed:
flush()
if not dying:
log.debug('Regexp cache size: %s', len(sre._cache))
log.debug('Pattern cache size: %s'%len(ircutils._patternCache))
log.debug('HostmaskPatternEqual cache size: %s' %
len(ircutils._hostmaskPatternEqualCache))
log.info('%s Flushers flushed and garbage collected.', log.timestamp())
timestamp = log.timestamp()
if flushed:
log.info('%s Flushers flushed and garbage collected.', timestamp)
else:
log.info('%s Garbage collected.', timestamp)
return collected
def makeDriversDie():