from json import load, dump, loads import redis from utils.loaders.command_loader import loadCommands from utils.logging.log import * r = redis.StrictRedis(unix_socket_path='/tmp/redis.sock', db=0) configPath = "conf/" certPath = "cert/" filemap = { "config": ["config.json", "configuration"], "keyconf": ["keyword.json", "keyword lists"], "pool": ["pool.json", "pool"], "help": ["help.json", "command help"], # "wholist": ["wholist.json", "WHO lists"], "counters": ["counters.json", "counters file"], "masterbuf": ["masterbuf.json", "master buffer"], "monitor": ["monitor.json", "monitoring database"], } connections = {} IRCPool = {} ReactorPool = {} FactoryPool = {} MonitorPool = [] CommandMap = {} def register(command, function): if not command in CommandMap: CommandMap[command] = function debug("Registered command: %s" % command) else: error("Duplicate command: %s" % (command)) def saveConf(var): with open(configPath+filemap[var][0], "w") as f: dump(globals()[var], f, indent=4) return def loadConf(var): with open(configPath+filemap[var][0], "r") as f: globals()[var] = load(f) def initConf(): for i in filemap.keys(): loadConf(i) def initMain(): initConf() loadCommands(register)