How to use the openpyn.filters.filter_by_load function in openpyn

To help you get started, we’ve selected a few openpyn examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jotyGill / openpyn-nordvpn / openpyn / openpyn.py View on Github external
p2p: bool, dedicated: bool, double_vpn: bool, tor_over_vpn: bool,
                        anti_ddos: bool, netflix: bool, location: float, stats: bool) -> List:
    if tcp:
        used_protocol = "OPENVPN-TCP"
    else:
        used_protocol = "OPENVPN-UDP"

    # use api.nordvpn.com
    json_res_list = api.get_data_from_api(
        country_code=country_code, area=area, p2p=p2p, dedicated=dedicated,
        double_vpn=double_vpn, tor_over_vpn=tor_over_vpn, anti_ddos=anti_ddos,
        netflix=netflix, location=location)

    server_list = filters.filter_by_protocol(json_res_list=json_res_list, tcp=tcp)

    better_servers_list = filters.filter_by_load(server_list, max_load, top_servers)

    if stats:
        print(Style.BRIGHT + Fore.BLUE + "According to NordVPN, \
Least Busy " + Fore.GREEN + str(len(better_servers_list)) + Fore.BLUE + " Servers in \
" + Fore.GREEN + country_code.upper() + Fore.BLUE, end=" ")
        if area:
            print("in Location" + Fore.GREEN, json_res_list[0]["location_names"], end=" ")

        print(Fore.BLUE + "With 'Load' Less Than", Fore.GREEN + str(max_load) + Fore.BLUE,
              "Which Support", Fore.GREEN + used_protocol, end=" ")
        if p2p:
            print(", p2p =", p2p, end=" ")
        if dedicated:
            print(", dedicated =", dedicated, end=" ")
        if double_vpn:
            print(", double_vpn =", double_vpn, end=" ")