def ESConnection():
parser = configparser.ConfigParser()
conf_file = 'settings'
fd = open(conf_file, 'r')
parser.readfp(fd)
fd.close()
sections = parser.sections()
for section in sections:
options = parser.options(section)
for option in options:
if option == 'user': user = parser.get(section, option)
if option == 'password': password = parser.get(section, option)
if option == 'host': host = parser.get(section, option)
if option == 'port': port = parser.get(section, option)
if option == 'path': path = parser.get(section, option)
if option == 'genderize_key': genderize_key = parser.get(section, option)
if option == 'index_gerrit_raw': es_read_gerrit_index = parser.get(section, option)
if option == 'index_git_raw': es_read_git_index = parser.get(section, option)
if option == 'host_output': host_output = parser.get(section, option)
if option == 'port_output': port_output = parser.get(section, option)
if option == 'user_output': user_output = parser.get(section, option)
if option == 'password_output': password_output = parser.get(section, option)
if option == 'path_output': path_output = parser.get(section, option)
if option == 'index_gerrit_output': es_write_gerrit_index = parser.get(section, option)
if option == 'index_git_output': es_write_git_index = parser.get(section, option)
connection = "https://" + user + ":" + password + "@" + host + ":" + port + "/"
print (connection)
es_read = Elasticsearch([connection], use_ssl=True, verity_certs=True, ca_cert=certifi.where(), scroll='300m', timeout=100)
connection_output = "https://" + user_output + ":" + password_output + "@" + host_output + ":" + port_output + "/" + path_output
es_write = Elasticsearch([connection_output], use_ssl=True, verity_certs=True, ca_cert=certifi.where(), scroll='300m', timeout=100)
return es_read, es_write, es_read_git_index, es_read_gerrit_index, \
es_write_git_index, es_write_gerrit_index, genderize_key
评论列表
文章目录