Correct browser mode issue and alias name

This commit is contained in:
Nicolargo 2014-12-02 19:17:43 +01:00
parent 2de175c9f2
commit c0a98cc7d2
3 changed files with 12 additions and 3 deletions

View File

@ -134,6 +134,7 @@ list_2_countmin=1
[serverlist]
# Define the static server list
server_1_name=localhost
server_1_alias=MonXPS
server_1_port=61234
server_2_name=localhost
server_2_port=61235

View File

@ -53,7 +53,7 @@ class GlancesStaticServer(object):
new_server = {}
postfix = 'server_%s_' % str(i)
# Read the server name (mandatory)
for s in ['name', 'port']:
for s in ['name', 'port', 'alias']:
new_server[s] = config.get_raw_option(self._section, '%s%s' % (postfix, s))
if new_server['name'] is not None:
# Manage optionnal information

View File

@ -1003,6 +1003,7 @@ class GlancesCursesBrowser(_GlancesCurses):
# Item description: [stats_id, column name, column size]
column_def = [
['name', _('Name'), 16],
['alias', None, None],
['load_min5', _('LOAD'), 6],
['cpu_percent', _('CPU%'), 5],
['mem_percent', _('MEM%'), 5],
@ -1017,7 +1018,7 @@ class GlancesCursesBrowser(_GlancesCurses):
cpt = 0
xc = x + 2
for c in column_def:
if xc < screen_x and y < screen_y:
if xc < screen_x and y < screen_y and c[1] is not None:
self.term_window.addnstr(y, xc,
c[1],
screen_x - x,
@ -1044,6 +1045,9 @@ class GlancesCursesBrowser(_GlancesCurses):
logger.debug(
"Can not grab stats {0} from server (KeyError: {1})".format(c[0], e))
server_stat[c[0]] = '?'
# Display alias instead of name
if c[0] == 'alias' and v[c[0]] is not None:
server_stat['name'] = v[c[0]]
# Display line for server stats
cpt = 0
@ -1057,9 +1061,13 @@ class GlancesCursesBrowser(_GlancesCurses):
screen_x - xc,
self.colors_list['BOLD'])
# Display alias instead of name
server_stat
# Display the line
xc += 2
for c in column_def:
if xc < screen_x and y < screen_y:
if xc < screen_x and y < screen_y and c[1] is not None:
# Display server stats
self.term_window.addnstr(y, xc,
"%s" % server_stat[c[0]],