Correct a bug when x size < caption len

This commit is contained in:
Nicolas Hennion 2012-12-10 22:54:43 +01:00
parent f4fdafdd2c
commit cf35e60826

View File

@ -828,8 +828,14 @@ class GlancesStats:
# PROCESS
self.glancesgrabprocesses.update()
self.process = self.glancesgrabprocesses.getlist()
self.processcount = self.glancesgrabprocesses.getcount()
process = self.glancesgrabprocesses.getlist()
processcount = self.glancesgrabprocesses.getcount()
if not hasattr(self, 'process'):
self.process = []
self.processcount = {}
else:
self.process = process
self.processcount = processcount
# Initialiation of the running processes list
# Data are refreshed every two cycle (refresh_time * 2)
@ -941,9 +947,6 @@ class GlancesStatsServer(GlancesStats):
self._init_host()
self.all_stats["host"] = self.host
# Init the process list
self.process_list_refresh = True
self.glancesgrabprocesses = GlancesGrabProcesses()
def __update__(self, input_stats):
"""
@ -1341,8 +1344,8 @@ class glancesScreen:
# Display stats
self.displaySystem(stats.getHost(), stats.getSystem())
cpu_offset = self.displayCpu(stats.getCpu(), stats.getPerCpu(), processlist)
self.displayLoad(stats.getLoad(), stats.getCore(), processlist, cpu_offset)
self.displayMem(stats.getMem(), stats.getMemSwap(), processlist, cpu_offset)
load_offset = self.displayLoad(stats.getLoad(), stats.getCore(), processlist, cpu_offset)
self.displayMem(stats.getMem(), stats.getMemSwap(), processlist, load_offset)
network_count = self.displayNetwork(stats.getNetwork())
sensors_count = self.displaySensors(stats.getSensors(),
self.network_y + network_count)
@ -1424,7 +1427,7 @@ class glancesScreen:
# Is it possible to display extended stats ?
# If yes then tag_extendedcpu = True
tag_extendedcpu = screen_x > self.cpu_x + 79 + 17
tag_extendedcpu = screen_x > self.cpu_x + 79 + 15
# Is it possible to display per-CPU stats ?
# Do you want it ?
@ -1570,7 +1573,7 @@ class glancesScreen:
self.term_window.addnstr(self.cpu_y + 3, self.cpu_x + 24,
"N/A", 3)
# return the x offset to display load and mem
# return the x offset to display load
return offset_x
def displayLoad(self, load, core, proclist, offset_x=0):
@ -1579,8 +1582,15 @@ class glancesScreen:
return 0
screen_x = self.screen.getmaxyx()[1]
screen_y = self.screen.getmaxyx()[0]
loadblocksize = 15
#~ test = max(0, (screen_x - (self.load_x + offset_x + loadblocksize)))
#~ self.term_window.addnstr(1, test, str(test), 3)
if (screen_y > self.load_y + 5 and
screen_x > self.load_x + offset_x + 18):
screen_x > self.load_x + offset_x + loadblocksize):
self.term_window.addnstr(self.load_y,
self.load_x + offset_x, _("Load"), 4,
self.title_color if self.hascolors else
@ -1614,6 +1624,9 @@ class glancesScreen:
self.load_x + offset_x + 8,
format(load['min15'], '>5.2f'), 5,
self.__colors_list[alert])
# return the x offset to display mem
return offset_x
def displayMem(self, mem, memswap, proclist, offset_x=0):
# Memory
@ -1621,8 +1634,13 @@ class glancesScreen:
return 0
screen_x = self.screen.getmaxyx()[1]
screen_y = self.screen.getmaxyx()[0]
memblocksize = 46
extblocksize = 18
memblocksize = 45
extblocksize = 15
#~ test = max(0, (screen_x - (self.mem_x + offset_x + + memblocksize - extblocksize)))
#~ self.term_window.addnstr(6, test, str(test), 3)
if (screen_y > self.mem_y + 5 and
screen_x > self.mem_x + offset_x + memblocksize - extblocksize):
@ -2259,8 +2277,10 @@ class glancesScreen:
self.caption_x + len(msg_client),
' | ' + msg_help, 3 + len(msg_help))
else:
self.term_window.addnstr(max(self.caption_y, screen_y - 1),
self.caption_x, msg_help, len(msg_help))
if (screen_y > self.caption_y and
screen_x > self.caption_x + len(msg_help)):
self.term_window.addnstr(max(self.caption_y, screen_y - 1),
self.caption_x, msg_help, len(msg_help))
def displayHelp(self):
"""