Advertisement
Guest User

Untitled

a guest
Jan 30th, 2018
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.58 KB | None | 0 0
  1. from steem import Steem
  2. from datetime import datetime
  3.  
  4. s = Steem(nodes=['https://api.steemit.com'])
  5. account = "ADD YOUR ACCOUNT NAME"
  6. account_data = s.get_account(account)
  7. global_data = s.get_dynamic_global_properties()
  8.  
  9. received_vesting_shares =float(account_data["received_vesting_shares"].replace(" VESTS", ""))
  10. vesting_shares = float(account_data["vesting_shares"].replace(" VESTS", ""))
  11. max_virtual_bandwidth = float(global_data["max_virtual_bandwidth"])
  12. total_vesting_shares = float(global_data["total_vesting_shares"].replace(" VESTS", ""))
  13.  
  14. allocated_bandwidth = (max_virtual_bandwidth * (vesting_shares + received_vesting_shares) / total_vesting_shares)
  15. allocated_bandwidth = round(allocated_bandwidth / 1000000)
  16.  
  17. total_seconds = 604800
  18. date_bandwidth = account_data["last_bandwidth_update"]
  19. date_bandwidth = datetime.strptime(date_bandwidth, "%Y-%m-%dT%H:%M:%S")
  20. seconds_since_last_update = datetime.utcnow() - date_bandwidth
  21. seconds_since_last_update = seconds_since_last_update.total_seconds()
  22. average_bandwidth = float(account_data["average_bandwidth"])
  23.  
  24. used_bandwidth = 0
  25. if seconds_since_last_update < total_seconds:
  26.     used_bandwidth = (((total_seconds - seconds_since_last_update) * average_bandwidth) / total_seconds)
  27. used_bandwidth = round(used_bandwidth / 1000000)
  28.  
  29. print("current bandwidth used: " + str(used_bandwidth))
  30. print("current bandwidth allocated: " + str(allocated_bandwidth))
  31. print("bandwidth percent used: " + str(100 * used_bandwidth / allocated_bandwidth))
  32. print("bandwidth percent remaining: " + str(100 - (100 * used_bandwidth / allocated_bandwidth)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement