summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico Schlömer <nico.schloemer@gmail.com>2022-03-11 10:39:31 +0100
committerGitHub <noreply@github.com>2022-03-11 10:39:31 +0100
commitdb9f3b93014a084cd4c19edb2819f7bbbf7a88b4 (patch)
tree4ab2a404fc0e28660994423f98ddf6e8154a2d55
parent82d5af9edb41d3f10a80f5bb81fd65b276bec903 (diff)
parent59fcd5201bcf1e9cf5e5dff9f5231e061d70becf (diff)
Merge pull request #83 from nschloe/auto-netv0.2.5
better auto net selection
-rw-r--r--src/tiptop/__about__.py2
-rw-r--r--src/tiptop/_net.py8
2 files changed, 6 insertions, 4 deletions
diff --git a/src/tiptop/__about__.py b/src/tiptop/__about__.py
index 788da1f..fe404ae 100644
--- a/src/tiptop/__about__.py
+++ b/src/tiptop/__about__.py
@@ -1 +1 @@
-__version__ = "0.2.4"
+__version__ = "0.2.5"
diff --git a/src/tiptop/_net.py b/src/tiptop/_net.py
index a66746b..c55e70c 100644
--- a/src/tiptop/_net.py
+++ b/src/tiptop/_net.py
@@ -44,9 +44,11 @@ def _autoselect_interface():
else:
score_dict[name] = 3
- # Get key with max score
- # https://stackoverflow.com/a/280156/353337
- return max(score_dict, key=score_dict.get)
+ # Amongst all keys with max score, get the alphabetically first.
+ # This is to prefer en0 over en5, <https://github.com/nschloe/tiptop/issues/81>.
+ max_score = max(score_dict.values())
+ max_keys = [key for key, score in score_dict.items() if score == max_score]
+ return sorted(max_keys)[0]
class Net(Widget):