Advertisement
kinos

Untitled

Dec 28th, 2016
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. def rpcgen(cmd,prm):
  2. ... r=random.randrange(1,65530,step=255)
  3. ... ps={"jsonrpc":"2.0","method":cmd,"params":prm,"id":str(r)}
  4. ... return json.dumps(ps).encode('utf-8')
  5. ...
  6. >>> type(rpcgen("admin.addPeer","1"))
  7. <class 'bytes'>
  8. >>> re=hc.request("POST","http://10.0.0.3:8545", headers={'Content-Type': 'application/json'},body=rpcgen("admin.addPeer","j"))
  9. Traceback (most recent call last):
  10. File "<input>", line 1, in <module>
  11. re=hc.request("POST","http://10.0.0.3:8545", headers={'Content-Type': 'application/json'},body=rpcgen("admin.addPeer","j"))
  12. File "/usr/lib/python3/dist-packages/urllib3/request.py", line 72, in request
  13. **urlopen_kw)
  14. File "/usr/lib/python3/dist-packages/urllib3/request.py", line 135, in request_encode_body
  15. **urlopen_kw)
  16. TypeError: urlopen() got multiple values for keyword argument 'body'
  17. >>> re=hc.request("POST","http://10.0.0.3:8545", headers={'Content-Type': 'application/json'})
  18. >>> re=hc.request("POST","http://10.0.0.3:8545",body=rpcgen("lll","ggg")headers={'Content-Type': 'application/json'})
  19. File "<input>", line 1
  20. re=hc.request("POST","http://10.0.0.3:8545",body=rpcgen("lll","ggg")headers={'Content-Type': 'application/json'})
  21. ^
  22. SyntaxError: invalid syntax
  23. >>> re=hc.request("POST","http://10.0.0.3:8545",body=rpcgen("lll","ggg"),headers={'Content-Type': 'application/json'})
  24. Traceback (most recent call last):
  25. File "<input>", line 1, in <module>
  26. re=hc.request("POST","http://10.0.0.3:8545",body=rpcgen("lll","ggg"),headers={'Content-Type': 'application/json'})
  27. File "/usr/lib/python3/dist-packages/urllib3/request.py", line 72, in request
  28. **urlopen_kw)
  29. File "/usr/lib/python3/dist-packages/urllib3/request.py", line 135, in request_encode_body
  30. **urlopen_kw)
  31. TypeError: urlopen() got multiple values for keyword argument 'body'
  32. >>> re=hc.request("POST","http://10.0.0.3:8545",body=rpcgen("lll","ggg"),headers={'Content-Type': 'application/json'})
  33. Traceback (most recent call last):
  34. File "<input>", line 1, in <module>
  35. re=hc.request("POST","http://10.0.0.3:8545",body=rpcgen("lll","ggg"),headers={'Content-Type': 'application/json'})
  36. File "/usr/lib/python3/dist-packages/urllib3/request.py", line 72, in request
  37. **urlopen_kw)
  38. File "/usr/lib/python3/dist-packages/urllib3/request.py", line 135, in request_encode_body
  39. **urlopen_kw)
  40. TypeError: urlopen() got multiple values for keyword argument 'body'
  41. >>> type(rpcgen("admin.addPeer","1"))
  42. <class 'bytes'>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement