45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
#!/usr/bin/python
|
|
# -*- coding:utf-8 _*-
|
|
"""
|
|
@author: pengtao
|
|
@file: check_json.py
|
|
@time: 2020/03/17
|
|
"""
|
|
import json
|
|
|
|
|
|
def get_csv():
|
|
with open('1.csv', 'r') as f:
|
|
data = f.read()
|
|
csv_data = list()
|
|
for line in data.split('\n'):
|
|
tt = {}
|
|
if line:
|
|
tt['serverid'], tt['redis_host'], tt['redis_port'] = line.split()
|
|
csv_data.append(tt)
|
|
return csv_data
|
|
|
|
|
|
def read_json(filename):
|
|
json_data = json.loads(open(filename, 'r').read())
|
|
return json_data
|
|
|
|
|
|
def main():
|
|
csv_data = get_csv()
|
|
for i in range(11, 15):
|
|
check_file = f"server_list_{i}.json"
|
|
json_data = read_json(check_file)
|
|
for line in json_data:
|
|
for csv_line in csv_data:
|
|
if int(line['serverid']) == int(csv_line['serverid']) :
|
|
if line['redis_host'] == csv_line['redis_host'] and int(line['redis_port']) == int(csv_line[\
|
|
'redis_port']):
|
|
pass
|
|
else:
|
|
print(line, csv_line, check_file)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|