提交 3bbe6371 编写于 作者: S sangoh.hong

Merge branch 'develop' into feature/curses-browser-paging

# Conflicts:
#	.gitignore
#	glances/outputs/glances_curses_browser.py
......@@ -48,4 +48,5 @@ _build
node_modules/
bower_components/
.vscode/
\ No newline at end of file
# visual stdio code
.vscode/
......@@ -12,6 +12,7 @@ Enhancements and new features:
* Sort docker stats #1276
* Prohibit some plug-in data from being exported to influxdb #1368
* Disable plugin from Glances configuration file #1378
* Curses-browser's server list paging added (thanks to @limfreee) #1385
Bugs corrected:
......
......@@ -219,12 +219,16 @@ class GlancesClientBrowser(object):
# It's done by the GlancesAutoDiscoverListener class (autodiscover.py)
# Or define staticaly in the configuration file (module static_list.py)
# For each server in the list, grab elementary stats (CPU, LOAD, MEM, OS...)
while True:
thread_list = {}
while self.screen.is_end == False:
logger.debug("Iter through the following server list: {}".format(self.get_servers_list()))
for v in self.get_servers_list():
thread = threading.Thread(target=self.__update_stats, args=[v])
thread.start()
key = v["key"]
thread = thread_list.get(key, None)
if thread is None or thread.is_alive() == False:
thread = threading.Thread(target=self.__update_stats, args=[v])
thread_list[key] = thread
thread.start()
# Update the screen (list or Glances client)
if self.screen.active_server is None:
......@@ -234,6 +238,10 @@ class GlancesClientBrowser(object):
# Display the active server
self.__display_server(self.get_servers_list()[self.screen.active_server])
# exit key pressed
for thread in thread_list.values():
thread.join()
def serve_forever(self):
"""Wrapper to the serve_forever function.
......
......@@ -61,6 +61,8 @@ class GlancesCursesBrowser(_GlancesCurses):
self._page_max = 0
self._page_max_lines = 0
self.is_end = False
@property
def active_server(self):
"""Return the active server or None if it's the browser list."""
......@@ -140,7 +142,8 @@ class GlancesCursesBrowser(_GlancesCurses):
# 'ESC'|'q' > Quit
self.end()
logger.info("Stop Glances client browser")
sys.exit(0)
# sys.exit(0)
self.is_end = True
elif self.pressedkey == 10:
# 'ENTER' > Run Glances on the selected server
self.active_server = self._current_page * self._page_max_lines + self.cursor_position
......@@ -291,7 +294,6 @@ class GlancesCursesBrowser(_GlancesCurses):
start_line = self._page_max_lines * self._current_page
end_line = start_line + self.get_pagelines(stats)
current_page = stats[start_line:end_line]
# Display table
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册