コード例 #1
0
ファイル: hermes_core.py プロジェクト: Ri0n/Hermes
    def run(self):
        log.msg("Init hermes logic unit instance")
        self.tagParser = TagParser()

        # preparing database
        self.db = sqlite3.connect(
            os.path.join(config()['spool']['path'],
                         config()['spool']['db']))
        self.db.isolation_level = None
        self.db.row_factory = sqlite3.Row

        c = self.db.cursor()
        c.execute('''CREATE TABLE IF NOT EXISTS contacts
                (id INTEGER PRIMARY KEY AUTOINCREMENT,
                 type INTEGER,
                 address TEXT,
                 privilege INTEGER,
                 subscription TEXT)''')
        c.execute('''CREATE UNIQUE INDEX IF NOT EXISTS uniq_contact_address
                ON contacts(type, address)''')

        self.contacts = ContactsManager()
        self.xmpp = xmpp.XmppMessenger()

        demon.init()
        super(HermesCore, self).run()