Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from steem import Steem
- from datetime import datetime
- s = Steem(nodes=['https://api.steemit.com'])
- account = "ADD YOUR ACCOUNT NAME"
- account_data = s.get_account(account)
- global_data = s.get_dynamic_global_properties()
- received_vesting_shares =float(account_data["received_vesting_shares"].replace(" VESTS", ""))
- vesting_shares = float(account_data["vesting_shares"].replace(" VESTS", ""))
- max_virtual_bandwidth = float(global_data["max_virtual_bandwidth"])
- total_vesting_shares = float(global_data["total_vesting_shares"].replace(" VESTS", ""))
- allocated_bandwidth = (max_virtual_bandwidth * (vesting_shares + received_vesting_shares) / total_vesting_shares)
- allocated_bandwidth = round(allocated_bandwidth / 1000000)
- total_seconds = 604800
- date_bandwidth = account_data["last_bandwidth_update"]
- date_bandwidth = datetime.strptime(date_bandwidth, "%Y-%m-%dT%H:%M:%S")
- seconds_since_last_update = datetime.utcnow() - date_bandwidth
- seconds_since_last_update = seconds_since_last_update.total_seconds()
- average_bandwidth = float(account_data["average_bandwidth"])
- used_bandwidth = 0
- if seconds_since_last_update < total_seconds:
- used_bandwidth = (((total_seconds - seconds_since_last_update) * average_bandwidth) / total_seconds)
- used_bandwidth = round(used_bandwidth / 1000000)
- print("current bandwidth used: " + str(used_bandwidth))
- print("current bandwidth allocated: " + str(allocated_bandwidth))
- print("bandwidth percent used: " + str(100 * used_bandwidth / allocated_bandwidth))
- print("bandwidth percent remaining: " + str(100 - (100 * used_bandwidth / allocated_bandwidth)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement