Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import requests
- def main():
- url = 'http://localhost:13331/'
- body = {
- 'jsonrpc': '2.0',
- 'method': 'getstats',
- 'id': 'foo',
- }
- stats = requests.post(url, json=body).json()
- share_map = sorted(
- stats['result']['share_map'].items(),
- key=lambda sharecount: sharecount[1],
- reverse=True,
- )
- pad_to = max(len(str(share[1])) for share in share_map)
- for address, shares in share_map:
- print(
- '{shares:{pad_to}} {address}'
- .format(shares=shares, pad_to=pad_to, address=address),
- )
- if __name__ == '__main__':
- main()
- # EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement