Repository navigation
Conversation
GlancesFilterList.filter appended to the existing list, so the property
never described the current filter: every assignment added to whatever was
already there. Its sibling in the same file, GlancesFilter.filter, replaces.
Both process_focus and export_process_filter are written twice in a normal
startup. The processlist plugin reads glances.conf when it loads
(plugins/processlist/__init__.py), and the command line is applied just
after -- set_args() for the focus filter, standalone.py for the export one.
Appending left both live, and is_filtered() ORs them, so
focus=.*firefox.* in glances.conf
glances --process-focus .*python.*
focused on firefox and python together. The command line could widen the
list from the configuration file but never narrow it, while config.rst
states that "options given on the command line overrides both".
Assigning the whole list restores that precedence: the configuration file
is read first, the command line replaces it.
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.
Description
GlancesFilterList.filterappends to the existing list rather than replacing it, sothe property never describes the current filter — each assignment adds to whatever
was already there. Its sibling in the same file,
GlancesFilter.filter, replaces.That matters because both
process_focusandexport_process_filterare writtentwice during a normal startup:
glances.confplugins/processlist/__init__.py:254plugins/processlist/__init__.py:250processes.py:163(set_args)standalone.py:71The plugin loads the configuration file first, the command line is applied just
after, and
is_filtered()ORs the accumulated list. So withGlances focuses on firefox and python together. The command line can widen the
list set in
glances.conf, but never narrow it — whiledocs/config.rststates:Assigning the whole list restores that precedence: the configuration file is read
first, the command line replaces it.
--process-focus a,bstill yields both, sincethat is one assignment.
Reproduced against
developbefore the change:Resume
Tests
Added to
test_020_filterintests/test_core.py: assign twice, assert the secondassignment is the whole filter. Verified by reverting
glances/filter.pyalone — thenew assertions fail with
['.*firefox.*', '.*python.*'] != ['.*python.*'], and everypre-existing assertion passes both with and without the change.
tests/test_core.py: 48 passed, 6 skipped. The process- and filter-related suites(
test_processes_cache,test_plugin_processcount,test_sort_missing_values,test_program_aggregation,test_globals,test_glances_stats,test_lazy_views):115 passed.
ruff checkclean;ruff format --checkreports only a pre-existingcomplaint at
tests/test_core.py:422, which is present on an unmodifieddevelop.