From b410a0c4ed36255d9d2a89bb924e710829b6043f Mon Sep 17 00:00:00 2001 From: desbma Date: Wed, 20 Apr 2016 00:46:12 +0200 Subject: [PATCH] Fix #849 - part 2 --- glances/plugins/glances_processlist.py | 48 ++++++++++++++------------ 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/glances/plugins/glances_processlist.py b/glances/plugins/glances_processlist.py index 0e38a86b..500f65a5 100644 --- a/glances/plugins/glances_processlist.py +++ b/glances/plugins/glances_processlist.py @@ -161,31 +161,33 @@ class Plugin(GlancesPlugin): child_data = new_child_data pos = new_pos - # draw node prefix - if is_last_child: - prefix = "└─" - else: - prefix = "├─" - child_data[pos[0]]["msg"] = prefix + if pos: + # draw node prefix + if is_last_child: + prefix = "└─" + else: + prefix = "├─" + child_data[pos[0]]["msg"] = prefix - # add indentation - for i in pos: - spacing = 2 - if first_level: - spacing = 1 - elif is_last_child and (i is not pos[0]): - # compensate indentation for missing '│' char - spacing = 3 - child_data[i]["msg"] = "%s%s" % (" " * spacing, child_data[i]["msg"]) - - if not is_last_child: - # add '│' tree decoration - for i in pos[1:]: - old_str = child_data[i]["msg"] + # add indentation + for i in pos: + spacing = 2 if first_level: - child_data[i]["msg"] = " │" + old_str[2:] - else: - child_data[i]["msg"] = old_str[:2] + "│" + old_str[3:] + spacing = 1 + elif is_last_child and (i is not pos[0]): + # compensate indentation for missing '│' char + spacing = 3 + child_data[i]["msg"] = "%s%s" % (" " * spacing, child_data[i]["msg"]) + + if not is_last_child: + # add '│' tree decoration + for i in pos[1:]: + old_str = child_data[i]["msg"] + if first_level: + child_data[i]["msg"] = " │" + old_str[2:] + else: + child_data[i]["msg"] = old_str[:2] + "│" + old_str[3:] + return child_data def get_process_curses_data(self, p, first, args):