Just importing repository_tool affects all of tuf logging (because it runs add_console_handler() and set_console_log_level()).
Probably because of this many tests and repo.py call some version of disable_console_log_messages().
This feels fragile and easy to accidentally misuse. I think the idea is that repository_tool.py is intended for "devops" use in an interactive python session... but then the same script is used in e.g. tests very much like a normal library.
If the interactive helper functionality is seen as important, I wonder if we should separate the use cases: keep the "library functionality" (that would not modify logging or even provide functions for doing that) and then provide a separate tool for interactive use, maybe something like this
repo_tool:
#!/bin/sh
python3 -i repo_tool_helper.py
repo_tool_helper.py
import tuf.repository_tool as repo_tool
import tuf.log
# setup tuf logging here as appropriate for this tool
now running repo_tool would give you an interactive python session with modules imported and logging setup appropriately.
Just importing repository_tool affects all of tuf logging (because it runs
add_console_handler()andset_console_log_level()).Probably because of this many tests and repo.py call some version of
disable_console_log_messages().This feels fragile and easy to accidentally misuse. I think the idea is that repository_tool.py is intended for "devops" use in an interactive python session... but then the same script is used in e.g. tests very much like a normal library.
If the interactive helper functionality is seen as important, I wonder if we should separate the use cases: keep the "library functionality" (that would not modify logging or even provide functions for doing that) and then provide a separate tool for interactive use, maybe something like this
repo_tool:
repo_tool_helper.py
now running
repo_toolwould give you an interactive python session with modules imported and logging setup appropriately.