This is a "bit more OOP" and easier to understand.
+ Unrelated change: Fix stupid range test I added to `Colors` -- has been bugging me since I noticed it :)
This patch is also a fix for environments lacking of systemd support (as
virt-what actually does not detect "wsl" fact).
Archey will now honor the logo of the Linux distribution WSL-emulated.
> closes #118
On Linux, we don't actually need `dmidecode` to gather hardware info.
This commit follows da5780e2 and simplify furthermore the `Model` entry
initialization.
Although it's only a first step, as `virt-what` uses `dmidecode` under
the hood.
In some virtual environments, `Model` might now show additional info.
> See <https://0pointer.net/blog/projects/no-more-dmidecode.html>
As new "custom" entries brings arbitrary command execution capabilities
in Archey code-base, we enforce some basic security checks to assert
loaded configuration files are not too "permissive".
The idea is to keep "W ^ X" enforced, so if another user _could_ write
to one of the configuration files, defined custom entries won't be
loaded.
Archey will consider a configuration file not too "permissive" if it
belongs to the running user (or the system administrator) **AND** if
group nor other users can write to it.
This patch brings a first support for "custom entries" to Archey. It
mainly allows users to run custom commands through their configuration
file.
In order to give "power to the user" for most of situations:
* STDERR output **MAY** be silenced through `log_stderr` option
* command exit status code **MAY** be ignored through `check` option
Multi-lines results will be joined on the same line, unless `one_line`
option is disabled.
Users **SHOULD** only enable `shell` option if they have to.
> See #111 for rationale.
This patch drops `os.getuid` usage in `Model`, for virtual environment
detection.
This way, additional information may be gathered if, for some reasons,
`virt-what` and/or `dmidecode` can be executed by the process owner.
It also drastically simplifies unit testing.
* [STYLE] Silences new Pylint recommendation C0209
* [CI] Forces macOS-10.15 as pypy 3.6 is unavailable afterwards (see actions/virtual-environments#4060)
Co-authored-by: Samuel FORESTIER <dev@samuel.domains>
+ also makes logging lines display the origin entry name
> Developers using Python API can now easily silence entries warning messages:
logging.getLogger('archey.entries.temperature').setLevel(logging.ERROR)