Refactor some code and update docs

This commit is contained in:
nicolargo 2024-04-28 09:21:58 +02:00
parent cc1ac3c6f5
commit c0284fbc69
5 changed files with 512 additions and 301 deletions

View File

@ -1,4 +1,5 @@
sphinx
sphinx_rtd_theme
ujson
reuse
setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability

View File

@ -3,7 +3,7 @@
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = ../venv/bin/sphinx-build
SPHINXBUILD = ../venv-dev/bin/sphinx-build
PAPER =
BUILDDIR = _build

File diff suppressed because it is too large Load Diff

View File

@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
.TH "GLANCES" "1" "Apr 25, 2024" "4.0.0_beta04" "Glances"
.TH "GLANCES" "1" "Apr 28, 2024" "4.0.0_beta04" "Glances"
.SH NAME
glances \- An eye on your system
.SH SYNOPSIS
@ -552,7 +552,7 @@ Furthermore, a configuration file is needed to access more settings.
.INDENT 0.0
.INDENT 3.5
A template is available in the \fB/usr{,/local}/share/doc/glances\fP
(Unix\-like) directory or directly on \fI\%GitHub\fP\&.
(Unix\-like) directory or directly on \X'tty: link https://raw.githubusercontent.com/nicolargo/glances/master/conf/glances.conf'\fI\%GitHub\fP\X'tty: link'\&.
.UNINDENT
.UNINDENT
.sp
@ -918,7 +918,7 @@ $ glances browser
.UNINDENT
.SH AUTHOR
.sp
Nicolas Hennion aka Nicolargo <\fI\%contact@nicolargo.com\fP>
Nicolas Hennion aka Nicolargo <\X'tty: link mailto:contact@nicolargo.com'\fI\%contact@nicolargo.com\fP\X'tty: link'>
.SH COPYRIGHT
2024, Nicolas Hennion
.\" Generated by docutils manpage writer.

View File

@ -157,7 +157,6 @@ class _GlancesCurses(object):
logger.critical("Cannot init the curses library ({})".format(e))
sys.exit(1)
# Load configuration file
self.load_config(config)
@ -205,7 +204,6 @@ class _GlancesCurses(object):
'left_menu',
default=self._left_sidebar)
def _init_history(self):
"""Init the history option."""
@ -439,7 +437,6 @@ class _GlancesCurses(object):
else:
self.enable_top()
def _handle_process_extended(self):
self.args.enable_process_extended = not self.args.enable_process_extended
if not self.args.enable_process_extended:
@ -620,6 +617,33 @@ class _GlancesCurses(object):
return ret
def set_number_of_processes(self, stat_display):
"""Set the number of processes to display
The value is dynamicaly computed."""
max_processes_displayed = (
self.term_window.getmaxyx()[0]
- 11
- (0 if 'containers' not in stat_display else self.get_stats_display_height(stat_display["containers"]))
- (
0
if 'processcount' not in stat_display
else self.get_stats_display_height(stat_display["processcount"])
)
- (0 if 'amps' not in stat_display else self.get_stats_display_height(stat_display["amps"]))
- (0 if 'alert' not in stat_display else self.get_stats_display_height(stat_display["alert"]))
)
try:
if self.args.enable_process_extended:
max_processes_displayed -= 4
except AttributeError:
pass
if max_processes_displayed < 0:
max_processes_displayed = 0
if glances_processes.max_processes is None or glances_processes.max_processes != max_processes_displayed:
logger.debug("Set number of displayed processes to {}".format(max_processes_displayed))
glances_processes.max_processes = max_processes_displayed
def display(self, stats, cs_status=None):
"""Display stats on the screen.
@ -643,29 +667,7 @@ class _GlancesCurses(object):
__stat_display = self.__get_stat_display(stats, layer=cs_status)
# Adapt number of processes to the available space
max_processes_displayed = (
self.term_window.getmaxyx()[0]
- 11
- (0 if 'containers' not in __stat_display else self.get_stats_display_height(__stat_display["containers"]))
- (
0
if 'processcount' not in __stat_display
else self.get_stats_display_height(__stat_display["processcount"])
)
- (0 if 'amps' not in __stat_display else self.get_stats_display_height(__stat_display["amps"]))
- (0 if 'alert' not in __stat_display else self.get_stats_display_height(__stat_display["alert"]))
)
try:
if self.args.enable_process_extended:
max_processes_displayed -= 4
except AttributeError:
pass
if max_processes_displayed < 0:
max_processes_displayed = 0
if glances_processes.max_processes is None or glances_processes.max_processes != max_processes_displayed:
logger.debug("Set number of displayed processes to {}".format(max_processes_displayed))
glances_processes.max_processes = max_processes_displayed
self.set_number_of_processes(__stat_display)
# Get the processlist
__stat_display["processlist"] = stats.get_plugin('processlist').get_stats_display(args=self.args)