MCPcopy Create free account
hub / github.com/CL-lau/SQL-GPT / initConfig

Method initConfig

memory/redisHelper.py:85–122  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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
125if __name__ == "__main__":

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected