summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicolargo <nicolashennion@gmail.com>2024-05-01 18:05:00 +0200
committernicolargo <nicolashennion@gmail.com>2024-05-01 18:05:00 +0200
commite0f7498b7e85fd215a1d55f1b126cccd44ef5809 (patch)
tree8a34966f3ed6aaf98717f100b34d25d3b67843df
parent21b49c7db20cddd66e171da50404a2764efc7648 (diff)
Add refresh to curses global loop
-rw-r--r--glances/outputs/glances_curses.py6
-rw-r--r--glances/standalone.py5
2 files changed, 9 insertions, 2 deletions
diff --git a/glances/outputs/glances_curses.py b/glances/outputs/glances_curses.py
index d95e63aa..e7e032f5 100644
--- a/glances/outputs/glances_curses.py
+++ b/glances/outputs/glances_curses.py
@@ -1130,6 +1130,10 @@ class _GlancesCurses(object):
update the terminal."""
self.term_window.erase()
+ def refresh(self):
+ """Refresh the windows"""
+ self.term_window.refresh()
+
def flush(self, stats, cs_status=None):
"""Erase and update the screen.
@@ -1139,8 +1143,10 @@ class _GlancesCurses(object):
"Connected": Client is connected to the server
"Disconnected": Client is disconnected from the server
"""
+ # See https://stackoverflow.com/a/43486979/1919431
self.erase()
self.display(stats, cs_status=cs_status)
+ self.refresh()
def update(self, stats, duration=3, cs_status=None, return_to_browser=False):
"""Update the screen.
diff --git a/glances/standalone.py b/glances/standalone.py
index 68700c8c..c28afe5e 100644
--- a/glances/standalone.py
+++ b/glances/standalone.py
@@ -148,15 +148,16 @@ class GlancesStandalone(object):
logger.debug('Stats updated duration: {} seconds'.format(counter.get()))
# Patch for issue1326 to avoid < 0 refresh
- adapted_refresh = self.refresh_time - counter.get()
- adapted_refresh = adapted_refresh if adapted_refresh > 0 else 0
+ adapted_refresh = (self.refresh_time - counter.get()) if (self.refresh_time - counter.get()) > 0 else 0
# Display stats
# and wait refresh_time - counter
if not self.quiet:
# The update function return True if an exit key 'q' or 'ESC'
# has been pressed.
+ counter_display = Counter()
ret = not self.screen.update(self.stats, duration=adapted_refresh)
+ logger.debug('Stats display duration: {} seconds'.format(counter_display.get() - adapted_refresh))
else:
# Nothing is displayed
# Break should be done via a signal (CTRL-C)