py访问Redis和zk操作

# -----------python访问redis集群-----------------------
from rediscluster import StrictRedisCluster
import requests

startup_nodes = [
{"host": "192.168.5.111", "port": 6379},
{"host": "192.168.5.112", "port": 6379},
{"host": "192.168.5.113", "port": 6379},
{"host": "192.168.5.114", "port": 6379},
{"host": "192.168.5.115", "port": 6379},
{"host": "192.168.5.116", "port": 6379}]

rc = StrictRedisCluster(startup_nodes=startup_nodes, decode_responses=True)
xx = rc.info('th:jsevent*')
x = rc.hgetall('t00')
y = rc.hgetall('th')
z = rc.hgetall('th0')


# -------------python访问zk,并设置或更新zk中字典-----------------------
from kazoo.client import KazooClient
import json
import requests

def login():
# 登录获取jwt
url1 = 'http://192.168.16.511:8100/sys/loginon'
payload1 = {'username': 'admin',
'password': '123456',
'validcode': '123548'}
r = requests.post(url1, data=payload1).cookies
# print(r['jwt'])

# 链接zk查看DebugSession
zk = KazooClient(hosts='192.168.1.1:2181') # 如果是本地那就写127.0.0.1
zk.start() # 与zookeeper连接
# node = zk.get_children('/wapn/test/')
data = {"RecvURL": "...?activityId=%d&destoken=%s",
"PacketPoolInsert": "...",
"FileUrl": "file",
"DomainUrl": "",
"ImageManaUrl": "he/",
"ResetLandUrl": "ssion",
"SSOPath": "sps",
"IsDebug": bool('true'),
"DebugSession": "",
"FileUploadPath": "/ho/files/"}
print('zk')
data['DebugSession'] = r['jwt']
zk.set('/czhhadmin/var', bytes(str(json.dumps(data, indent=2)), encoding='utf-8'))
print(json.dumps(data, indent=2))


login()


转载于:https://www.cnblogs.com/wapn/p/10626552.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值