Skip to content

Commit

Permalink
refactor(Rafficer#367): use new fn with 2nd dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
marcel-engelke committed Mar 24, 2024
1 parent 92353fc commit 6da664e
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions protonvpn_cli/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ def show_dialog(headline, choices, stop=False):

pull_server_data()

features = {
1: "Secure-Core",
2: "Tor",
4: "P2P",
8: "Streaming",
}
server_tiers = {0: "F", 1: "B", 2: "P"}

servers = get_servers()
Expand Down Expand Up @@ -106,21 +100,17 @@ def show_dialog(headline, choices, stop=False):
get_server_value(servername, "Load", servers)
).rjust(3, " ")

servers_features = []
feat = int(get_server_value(servername, 'Features', servers))
for bit_flag in features:
if (feat & bit_flag) != 0:
servers_features.append(features[bit_flag])
server_features = get_server_features(servername, servers)

if len(servers_features) == 0:
servers_features.append("Normal")
if len(server_features) == 0:
server_features.append("Normal")

tier = server_tiers[
get_server_value(servername, "Tier", servers)
]

choices.append((servername, "Load: {0}% | {1} | {2}".format(
load, tier, ", ".join(servers_features)
load, tier, ", ".join(server_features)
)))

server_result = show_dialog("Choose the server to connect:", choices)
Expand Down

0 comments on commit 6da664e

Please sign in to comment.