initial commit
[synarere.git] / core / __init__.py
blobeef14cc03a87a02d8f7748eaf47cb1d7c2213049
1 # synarere -- a highly modular and stable IRC bot.
2 # Copyright (C) 2010 Michael Rodriguez.
3 # Rights to this code are documented in docs/LICENSE.
5 '''Initialization code.'''
7 __all__ = ['command', 'confparse', 'event', 'io', 'irc', 'logger', 'module', 'timer', 'var']
9 def shutdown(code, reason):
10 '''Exit gracefully.'''
12 pid_file = None
14 # Import required Python functions.
15 from sys import exit
16 from os import remove
18 # Import required source modules.
19 import logger, var, irc, module
21 logger.info('shutdown(): exiting with code %d: %s' % (code, reason))
22 irc.quit_all('shutdown(): exiting with code %d: %s' % (code, reason))
23 module.unload_all()
25 # Remove the PID file.
26 try:
27 pid_file = open(var.conf.get('options', 'pidfile')[0], 'r')
28 remove(pid_file)
29 except IOError:
30 pass
32 exit(code)