def api_quota(tail=False): """ Check the API quota balance. Use --tail for updates every 0.25 seconds. """ from nextbus import Nextbus if tail: try: while True: remaining_mb = Nextbus.remaining_quota() / 1024**2 sys.stdout.write("\rNextbus Quota: {0:.3f} MB remaining.".format(remaining_mb)) sys.stdout.flush() time.sleep(0.25) except KeyboardInterrupt: print("") sys.exit() else: remaining_mb = Nextbus.remaining_quota() / 1024**2 print("Nextbus Quota: {0:.3f} MB remaining.".format(remaining_mb))
def api_quota(tail=False): """ Check the API quota balance. Use --tail for updates every 0.25 seconds. """ from nextbus import Nextbus if tail: try: while True: remaining_mb = Nextbus.remaining_quota() / 1024**2 sys.stdout.write( "\rNextbus Quota: {0:.3f} MB remaining.".format( remaining_mb)) sys.stdout.flush() time.sleep(0.25) except KeyboardInterrupt: print("") sys.exit() else: remaining_mb = Nextbus.remaining_quota() / 1024**2 print("Nextbus Quota: {0:.3f} MB remaining.".format(remaining_mb))