Commit 53d1971d authored by 张彦钊's avatar 张彦钊

change test file

parent 83c781a9
...@@ -158,22 +158,22 @@ def question_write(device_id,cid): ...@@ -158,22 +158,22 @@ def question_write(device_id,cid):
cursor.execute(sql) cursor.execute(sql)
result = cursor.fetchall() result = cursor.fetchall()
db.close() db.close()
cids = [str(i[0]) for i in result] cids = [i[0] for i in result]
if len(cids) != 0: if len(cids) != 0:
r = redis.Redis(host="172.16.40.135", port=5379, password="") r = redis.Redis(host="172.16.40.135", port=5379, password="", db=2)
key = str(device_id) + "_dislike_question" key = str(device_id) + "_dislike_question"
if r.exists(key): if r.exists(key):
value = eval(r.get(key)).split(",") value = json.loads(r.get(key).decode('utf-8'))
value.extend(cids) value.extend(cids)
value = ",".join([str(i) for i in set(value)])
cids = json.dumps(value) cids = json.dumps(value)
r.set(key, cids) r.set(key, cids)
print("cuznai") print("cunza")
else: else:
r.set(key, json.dumps(",".join(cids))) r.set(key, json.dumps(cids))
r.expire(key, 7 * 24 * 60 * 60) r.expire(key, 7 * 24 * 60 * 60)
print("bucunza")
return "question good" return "question good"
except Exception as e: except Exception as e:
...@@ -238,7 +238,8 @@ def diary_write(device_id,cid): ...@@ -238,7 +238,8 @@ def diary_write(device_id,cid):
# ssc.start() # ssc.start()
# ssc.awaitTermination() # ssc.awaitTermination()
diary_write("hello",16283654) question_write("hello",176661)
question_write("hello",226749)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment