Advertisement
Guest User

Untitled

a guest
Aug 30th, 2018
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. import requests
  3.  
  4.  
  5. def main():
  6.     url = 'http://localhost:13331/'
  7.     body = {
  8.         'jsonrpc': '2.0',
  9.         'method': 'getstats',
  10.         'id': 'foo',
  11.         }
  12.     stats = requests.post(url, json=body).json()
  13.  
  14.     share_map = sorted(
  15.         stats['result']['share_map'].items(),
  16.         key=lambda sharecount: sharecount[1],
  17.         reverse=True,
  18.         )
  19.     pad_to = max(len(str(share[1])) for share in share_map)
  20.  
  21.     for address, shares in share_map:
  22.         print(
  23.             '{shares:{pad_to}}    {address}'
  24.             .format(shares=shares, pad_to=pad_to, address=address),
  25.             )
  26.  
  27.  
  28. if __name__ == '__main__':
  29.     main()
  30.  
  31.  
  32. # EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement