# region ############################# IMPORTS ############################# import logging from debug import setup_logging log = logging.getLogger("default") setup_logging() import os from datetime import datetime from peewee import * from playhouse.sqlite_ext import SqliteExtDatabase #, FTS5Model, SearchField from configuration import read_config, write_config from paths import DATA_DIR # endregion # region ############################# GLOBALS ############################# realpath = os.path.dirname(os.path.realpath(__file__)) rp = realpath db_path = os.path.join(DATA_DIR, 'database.db') pragmas = [('journal_mode', 'wal'), ('cache_size', -1000 * 32)] db = SqliteExtDatabase(db_path, pragmas=pragmas) # endregion # region ############################# TABLE CLASSES ############################# class BroModel(Model):
def sig_handler(signum, frame): transport.offlinemsg = 'Signal handler called with signal %s' % (signum,) logger.info('Signal handler called with signal %s' % (signum,)) transport.online = 0 if __name__ == '__main__': if not load_config(): # Could not find/load a config file: exit. sys.stderr.write(("Configuration file not found. " "You need to create a config file and put it " " in one of these locations:\n ") + "\n ".join(config.configFiles)) sys.exit(1) debug_module.setup_logging() if config.pidFile: write_pid_file(config.pidFile) if config.saslUsername: sasl = 1 else: config.saslUsername = config.jid sasl = 0 # If the required files/directories are not writable, die. if not check_spool_directories(config.spoolFile, config.refreshTokenDirectory): sys.exit(1) connection = xmpp.client.Component(config.jid,
transport.offlinemsg = 'Signal handler called with signal %s' % (signum, ) logger.info('Signal handler called with signal %s' % (signum, )) transport.online = 0 if __name__ == '__main__': if not load_config(): # Could not find/load a config file: exit. sys.stderr.write(("Configuration file not found. " "You need to create a config file and put it " " in one of these locations:\n ") + "\n ".join(config.configFiles)) sys.exit(1) debug_module.setup_logging() if config.pidFile: write_pid_file(config.pidFile) if config.saslUsername: sasl = 1 else: config.saslUsername = config.jid sasl = 0 # If the required files/directories are not writable, die. if not check_spool_directories(config.spoolFile, config.refreshTokenDirectory): sys.exit(1)