make the module saving a bit more consistent

This commit is contained in:
Brian S. Stephan 2011-01-08 00:44:37 -06:00
parent 88d2a530c3
commit faf37447cf

View File

@ -239,20 +239,18 @@ class DrBotIRC(irclib.IRC):
def quit_irc(self, connection, msg):
for module in self.modlist:
module.save()
module.shutdown()
connection.quit(msg)
self.save_config()
print(self.save_config())
sys.exit()
def save_config(self):
with open('dr.botzo.cfg', 'w') as cfg:
self.config.write(cfg)
for module in self.modlist:
module.save()
return 'Saved.'
return 'Saved config.'
def load_module(self, modname):
"""Load a module (in both the python and dr.botzo sense) if not
@ -289,6 +287,7 @@ class DrBotIRC(irclib.IRC):
for module in self.modlist:
if modname == module.__class__.__name__:
# do anything the module needs to do to clean up
module.save()
module.shutdown()
# remove module references
@ -325,6 +324,10 @@ class DrBotIRC(irclib.IRC):
# SIGINT signal handler
def sigint_handler(self, signal, frame):
for module in self.modlist:
module.save()
module.shutdown()
print(self.save_config())
sys.exit()