| 83 | callback(message['channel'], message['data']) |
| 84 | |
| 85 | def initConfig(self): |
| 86 | if os.path.exists(self.config_file): |
| 87 | with open(self.config_file, 'r') as config_file: |
| 88 | config = json.load(config_file) |
| 89 | redis_config = config['redis'] |
| 90 | |
| 91 | host = None |
| 92 | port = None |
| 93 | db = None |
| 94 | pool_size = None |
| 95 | password = None |
| 96 | |
| 97 | if 'host' in redis_config.keys(): |
| 98 | host = redis_config['host'] |
| 99 | if 'port' in redis_config.keys(): |
| 100 | port = redis_config['port'] |
| 101 | if 'db' in redis_config.keys(): |
| 102 | db = redis_config['db'] |
| 103 | if 'pool_size' in redis_config.keys(): |
| 104 | pool_size = redis_config['pool_size'] |
| 105 | if 'password' in redis_config.keys(): |
| 106 | password = redis_config['password'] |
| 107 | |
| 108 | if host is not None and host != "" and self.host is None: |
| 109 | logging.info("set redis host as " + host) |
| 110 | self.host = host |
| 111 | if port is not None and port != -1 and self.port is None: |
| 112 | logging.info("set redis port as " + str(port)) |
| 113 | self.port = port |
| 114 | if db is not None and db != -1 and self.db is None: |
| 115 | self.db = db |
| 116 | logging.info("set redis db as " + str(db)) |
| 117 | if pool_size is not None and pool_size != -1 and self.pool_size is None: |
| 118 | logging.info("set redis pool_size as " + str(pool_size)) |
| 119 | self.pool_size = pool_size |
| 120 | if password is not None and password != "" and self.password is None: |
| 121 | logging.info("set redis password as " + password) |
| 122 | self.password = password |
| 123 | |
| 124 | |
| 125 | if __name__ == "__main__": |