def Run(): import logging #logging.basicConfig(level=logging.DEBUG, format='%(levelname)-8s %(message)s') pid = Config.get().core.pid spool_dir = Config.get().core.spool args = Config.get().optargs (pid_dir, name) = os.path.split(pid) print name.split('.pid')[0] print pid_dir daemon = Daemon(name=name.split('.pid')[0], pid_dir=pid_dir, stdin=spool_dir, stdout=spool_dir, stderr=spool_dir) if 'start' in args[0]: daemon.start() core = Core() core.run() elif 'stop' in args[0]: daemon.stop() elif 'status' in args[0]: daemon.status() else: print 'Wut?' print args
def __init__(self): self._config = Config.get().core self._book_keeper = BookKeeper(os.path.join(self._config.spool, 'bookkeeper.db')) self._book_keeper.reflect_services(self._config) self._room_map = {} self._xmpp = sleekxmpp.componentxmpp.ComponentXMPP( self._config.jid, self._config.secret, self._config.server, self._config.port) # setup callbacks self._xmpp.add_event_handler('message', self._on_message) self._xmpp.add_event_handler('changed_status', self._on_presence) self._xmpp.add_event_handler('got_offline', self._on_presence) # load additional plugins for plugin in ['xep_0004', 'xep_0030', 'xep_0050']: self._xmpp.registerPlugin(plugin) # setup xmpp discovery information self._xmpp.plugin['xep_0030'].identities['main'] = [] self._xmpp.plugin['xep_0030'].add_identity(category='client', itype='AI', name='Satori') self._xmpp.plugin['xep_0030'].add_identity(category='conference', itype='microblog', name='Satori') self._xmpp.plugin['xep_0030'].add_feature('http://jabber.org/protocol/muc')