Esempio n. 1
0
def _options_vpn(provider):
    name, _ = provider.get_metadata()
    print(("Options for %s:\n" % name))
    options = provider.get_options()

    # Print heading
    row = "{:18}" * 6
    print(
        row.format("Name", "Protocol", "Bandwidth", "Speed",
                   "Est. Price (mBTC)", "Price (USD)"))

    for option in options:
        bandwidth = "Unlimited" if option.bandwidth == sys.maxsize else str(
            option.bandwidth)
        speed = "Unlimited" if option.speed == sys.maxsize else option.speed

        # Calculate the estimated price
        rate = wallet_util.get_rate("USD")
        fee = wallet_util.get_network_fee()
        gateway = provider.get_gateway()
        estimate = gateway.estimate_price(option.price * rate) + fee  # BTC
        estimate = round(1000 * estimate, 2)  # mBTC

        print(
            row.format(option.name, option.protocol, bandwidth, speed,
                       str(estimate), str(option.price)))
Esempio n. 2
0
def _options_vps(p):
    name, _ = p.get_metadata()
    print(("Options for %s:\n" % name))
    options = p.get_options()

    # Print heading
    row = "{:<5}" + "{:20}" * 8
    print(
        row.format("#", "Name", "Cores", "Memory (GB)", "Storage (GB)",
                   "Bandwidth", "Connection (Gbit/s)", "Est. Price (mBTC)",
                   "Price (USD)"))

    for i, option in enumerate(options):
        bandwidth = "Unlimited" if option.bandwidth == sys.maxsize else str(
            option.bandwidth)

        # Calculate the estimated price
        rate = wallet_util.get_rate("USD")
        fee = wallet_util.get_network_fee()
        gateway = p.get_gateway()
        estimate = gateway.estimate_price(option.price * rate) + fee  # BTC
        estimate = round(1000 * estimate, 2)  # mBTC

        print(
            row.format(i, option.name, str(option.cores), str(option.memory),
                       str(option.storage), bandwidth, str(option.connection),
                       str(estimate), str(option.price)))