Skip to content

Commit

Permalink
Resolve the issue on Alpine
Browse files Browse the repository at this point in the history
This resolve the issue #208 :
This remove the "/" in the regex and order the server by only mean ping if the mean deviation is not present.
  • Loading branch information
Omegagoth authored Oct 13, 2018
1 parent bd993a0 commit 7264209
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions openpyn/openpyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ def ping_servers(better_servers_list: List, pings: str, stats: bool) -> List:
stdout=subprocess.PIPE)
# pipe the output of ping to grep.
ping_output = subprocess.check_output(
["grep", "-B", "1", "min/avg/max/"], stdin=ping_proc.stdout)
["grep", "-B", "1", "min/avg/max"], stdin=ping_proc.stdout)

ping_string = str(ping_output)
# logger.debug(ping_string)
Expand All @@ -557,8 +557,12 @@ def ping_servers(better_servers_list: List, pings: str, stats: bool) -> List:
ping_result.append(ping_list)
# logger.debug(ping_result)
pinged_servers_list.append(ping_result)
# sort by Ping Avg and Median Deviation
pinged_servers_list = sorted(pinged_servers_list, key=lambda item: (item[1][1], item[1][3]))
if len(pinged_servers_list[0][1]) >= 4:
# sort by Ping Avg and Median Deviation
pinged_servers_list = sorted(pinged_servers_list, key=lambda item: (item[1][1], item[1][3]))
else:
# sort by Ping Avg
pinged_servers_list = sorted(pinged_servers_list, key=lambda item: item[1][1])
return pinged_servers_list


Expand Down

0 comments on commit 7264209

Please sign in to comment.