Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def rpcgen(cmd,prm):
- ... r=random.randrange(1,65530,step=255)
- ... ps={"jsonrpc":"2.0","method":cmd,"params":prm,"id":str(r)}
- ... return json.dumps(ps).encode('utf-8')
- ...
- >>> type(rpcgen("admin.addPeer","1"))
- <class 'bytes'>
- >>> re=hc.request("POST","http://10.0.0.3:8545", headers={'Content-Type': 'application/json'},body=rpcgen("admin.addPeer","j"))
- Traceback (most recent call last):
- File "<input>", line 1, in <module>
- re=hc.request("POST","http://10.0.0.3:8545", headers={'Content-Type': 'application/json'},body=rpcgen("admin.addPeer","j"))
- File "/usr/lib/python3/dist-packages/urllib3/request.py", line 72, in request
- **urlopen_kw)
- File "/usr/lib/python3/dist-packages/urllib3/request.py", line 135, in request_encode_body
- **urlopen_kw)
- TypeError: urlopen() got multiple values for keyword argument 'body'
- >>> re=hc.request("POST","http://10.0.0.3:8545", headers={'Content-Type': 'application/json'})
- >>> re=hc.request("POST","http://10.0.0.3:8545",body=rpcgen("lll","ggg")headers={'Content-Type': 'application/json'})
- File "<input>", line 1
- re=hc.request("POST","http://10.0.0.3:8545",body=rpcgen("lll","ggg")headers={'Content-Type': 'application/json'})
- ^
- SyntaxError: invalid syntax
- >>> re=hc.request("POST","http://10.0.0.3:8545",body=rpcgen("lll","ggg"),headers={'Content-Type': 'application/json'})
- Traceback (most recent call last):
- File "<input>", line 1, in <module>
- re=hc.request("POST","http://10.0.0.3:8545",body=rpcgen("lll","ggg"),headers={'Content-Type': 'application/json'})
- File "/usr/lib/python3/dist-packages/urllib3/request.py", line 72, in request
- **urlopen_kw)
- File "/usr/lib/python3/dist-packages/urllib3/request.py", line 135, in request_encode_body
- **urlopen_kw)
- TypeError: urlopen() got multiple values for keyword argument 'body'
- >>> re=hc.request("POST","http://10.0.0.3:8545",body=rpcgen("lll","ggg"),headers={'Content-Type': 'application/json'})
- Traceback (most recent call last):
- File "<input>", line 1, in <module>
- re=hc.request("POST","http://10.0.0.3:8545",body=rpcgen("lll","ggg"),headers={'Content-Type': 'application/json'})
- File "/usr/lib/python3/dist-packages/urllib3/request.py", line 72, in request
- **urlopen_kw)
- File "/usr/lib/python3/dist-packages/urllib3/request.py", line 135, in request_encode_body
- **urlopen_kw)
- TypeError: urlopen() got multiple values for keyword argument 'body'
- >>> type(rpcgen("admin.addPeer","1"))
- <class 'bytes'>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement