def updateDB(file_db, msg):
db = init_DB(file_db)
if not db:
data = msg
else:
namelist = db['??'].split(",")
if msg['??'] not in namelist:
namelist.append(msg['??'])
db['??'] = ",".join(namelist)
try:
db['eventid'] = db['eventid'] + "," + msg['eventid']
except:
pass
# if db['??'] != msg['??']:
# db['??'] = db['??'] + "," + msg['??']
if "IP" in msg and "IP" in db:
if db['IP'] != msg['IP']:
db['IP'] = db['IP'] + "," + msg['IP']
db['??'] = db['??'] + msg['??']
data = db
with open(file_db, 'w') as f:
fcntl.flock(f, fcntl.LOCK_EX)
json.dump(data, f, ensure_ascii=False)
fcntl.flock(f, fcntl.LOCK_UN)
评论列表
文章目录