Repository navigation
fix(wifi): honour a partially configured set of signal thresholds - #3691
Merged
nicolargo merged 1 commit intoAug 26, 2026
Merged
Conversation
WifiPlugin.get_alert chained its three comparisons, so the first undefined level was compared against None, raised TypeError, and the blanket handler dropped the result to DEFAULT. Because 'critical' is tested first, leaving it out silenced the other two: a config defining only wifi_careful produced no alert at all, and even a strong signal came back undecorated instead of OK. GlancesPluginModel.get_alert already guards each level separately, and the sensors plugin has tests pinning that partial thresholds work. This brings wifi in line. `is not None` rather than truthiness because these limits are negative dBm values, where `if threshold` would discard a 0. The TypeError handler is kept for a non-numeric signal level (issue nicolargo#1373) but narrowed to that case, which is now the only way it can fire.
Owner
|
Thanks @ntdatt812 Just merged into develop branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The defect
WifiPlugin.get_alertoverrides the base implementation and chains its three comparisons (glances/plugins/wifi/__init__.py:146):get_limitreturnsNonefor a level the config does not define (plugin/model.py:969).value <= NoneraisesTypeError, the blanket handler catches it, and the whole result collapses toDEFAULT.Because
criticalis tested first, omitting it silences the other two as well.Measured on
developA user who sets just
wifi_carefulinglances.confgets no wifi alert at all, silently.The fix
Each level is read once and guarded on its own, the way
GlancesPluginModel.get_alertalready does (plugin/model.py:854-862) — and the way the sensors plugin is already tested for (test_partial_type_thresholds_are_used,test_partial_sensor_thresholds_are_used).Two details worth calling out:
is not None, not truthiness. The base class usesif critical and value >= critical. These limits are negative dBm values, so a0threshold would be discarded by a truthiness test;is not Noneis exact.TypeErrorhandler is kept but narrowed. It was added for issue TypeError on opening (Wifi plugin) #1373 (a non-numeric signal level). With theNonecomparisons gone that is now the only way it can fire, so it still does its original job and nothing else.KeyErroris dropped becauseget_limitreturnsNonerather than raising.After:
Tests
New
tests/test_plugin_wifi.py, 13 cases:carefulonly,warningonly,criticalonly);OKunder any partial config, not undecorated;DEFAULT;DEFAULT— the TypeError on opening (Wifi plugin) #1373 guard.5 of the 13 fail on
developand all 13 pass with the patch.