mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-30 01:37:17 +00:00
Added comments
This commit is contained in:
parent
ff1df07b5d
commit
9199ea3f0e
1 changed files with 23 additions and 10 deletions
|
@ -27,27 +27,35 @@ command_restart_module = "screen -S \"Script\" -X screen -t \"{}\" bash -c \"./{
|
||||||
printarrayGlob = [None]*14
|
printarrayGlob = [None]*14
|
||||||
lastTimeKillCommand = {}
|
lastTimeKillCommand = {}
|
||||||
|
|
||||||
|
# Used to pass information through scenes
|
||||||
current_selected_value = 0
|
current_selected_value = 0
|
||||||
current_selected_queue = ""
|
current_selected_queue = ""
|
||||||
current_selected_action = ""
|
current_selected_action = ""
|
||||||
current_selected_action = 0
|
current_selected_action = 0
|
||||||
|
|
||||||
|
# Map PID to Queue name (For restart and killing)
|
||||||
PID_NAME_DICO = {}
|
PID_NAME_DICO = {}
|
||||||
|
|
||||||
|
# Tables containing info for the dashboad
|
||||||
TABLES = {"running": [], "idle": [], "notRunning": [], "logs": [("No events recorded yet", 0)]}
|
TABLES = {"running": [], "idle": [], "notRunning": [], "logs": [("No events recorded yet", 0)]}
|
||||||
TABLES_TITLES = {"running": "", "idle": "", "notRunning": "", "logs": ""}
|
TABLES_TITLES = {"running": "", "idle": "", "notRunning": "", "logs": ""}
|
||||||
TABLES_PADDING = {"running": [12, 23, 8, 8, 23, 10, 55, 11, 11, 12], "idle": [9, 23, 8, 12, 50], "notRunning": [9, 23, 35], "logs": [15, 23, 8, 50]}
|
TABLES_PADDING = {"running": [12, 23, 8, 8, 23, 10, 55, 11, 11, 12], "idle": [9, 23, 8, 12, 50], "notRunning": [9, 23, 35], "logs": [15, 23, 8, 50]}
|
||||||
|
|
||||||
|
# Indicator for the health of a queue (green(0), red(2), yellow(1))
|
||||||
QUEUE_STATUS = {}
|
QUEUE_STATUS = {}
|
||||||
|
|
||||||
|
# Maintain the state of the CPU objects
|
||||||
CPU_TABLE = {}
|
CPU_TABLE = {}
|
||||||
CPU_OBJECT_TABLE = {}
|
CPU_OBJECT_TABLE = {}
|
||||||
|
|
||||||
|
# Path of the current paste for a pid
|
||||||
COMPLETE_PASTE_PATH_PER_PID = {}
|
COMPLETE_PASTE_PATH_PER_PID = {}
|
||||||
|
|
||||||
'''
|
'''
|
||||||
ASCIIMATICS WIDGETS EXTENSION
|
ASCIIMATICS WIDGETS EXTENSION
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
# Custom listbox
|
||||||
class CListBox(ListBox):
|
class CListBox(ListBox):
|
||||||
|
|
||||||
def __init__(self, queue_name, *args, **kwargs):
|
def __init__(self, queue_name, *args, **kwargs):
|
||||||
|
@ -88,6 +96,8 @@ class CListBox(ListBox):
|
||||||
self._x + self._offset + dx,
|
self._x + self._offset + dx,
|
||||||
self._y + i + dy - self._start_line,
|
self._y + i + dy - self._start_line,
|
||||||
colour, attr, bg)
|
colour, attr, bg)
|
||||||
|
|
||||||
|
# Pick color depending on queue health
|
||||||
if self.queue_name == "running":
|
if self.queue_name == "running":
|
||||||
if QUEUE_STATUS[pid] == 2:
|
if QUEUE_STATUS[pid] == 2:
|
||||||
queueStatus = Screen.COLOUR_RED
|
queueStatus = Screen.COLOUR_RED
|
||||||
|
@ -108,10 +118,12 @@ class CListBox(ListBox):
|
||||||
# Move up one line in text - use value to trigger on_select.
|
# Move up one line in text - use value to trigger on_select.
|
||||||
self._line = max(0, self._line - 1)
|
self._line = max(0, self._line - 1)
|
||||||
self.value = self._options[self._line][1]
|
self.value = self._options[self._line][1]
|
||||||
|
|
||||||
elif len(self._options) > 0 and event.key_code == Screen.KEY_DOWN:
|
elif len(self._options) > 0 and event.key_code == Screen.KEY_DOWN:
|
||||||
# Move down one line in text - use value to trigger on_select.
|
# Move down one line in text - use value to trigger on_select.
|
||||||
self._line = min(len(self._options) - 1, self._line + 1)
|
self._line = min(len(self._options) - 1, self._line + 1)
|
||||||
self.value = self._options[self._line][1]
|
self.value = self._options[self._line][1]
|
||||||
|
|
||||||
elif len(self._options) > 0 and event.key_code == ord(' '):
|
elif len(self._options) > 0 and event.key_code == ord(' '):
|
||||||
global current_selected_value, current_selected_queue
|
global current_selected_value, current_selected_queue
|
||||||
if self.queue_name == "logs":
|
if self.queue_name == "logs":
|
||||||
|
@ -128,6 +140,7 @@ class CListBox(ListBox):
|
||||||
else:
|
else:
|
||||||
# Ignore any other key press.
|
# Ignore any other key press.
|
||||||
return event
|
return event
|
||||||
|
|
||||||
elif isinstance(event, MouseEvent):
|
elif isinstance(event, MouseEvent):
|
||||||
# Mouse event - rebase coordinates to Frame context.
|
# Mouse event - rebase coordinates to Frame context.
|
||||||
new_event = self._frame.rebase_event(event)
|
new_event = self._frame.rebase_event(event)
|
||||||
|
@ -153,6 +166,7 @@ class CListBox(ListBox):
|
||||||
return event
|
return event
|
||||||
|
|
||||||
|
|
||||||
|
# Custom label centered in the middle
|
||||||
class CLabel(Label):
|
class CLabel(Label):
|
||||||
def __init__(self, label, listTitle=False):
|
def __init__(self, label, listTitle=False):
|
||||||
super(Label, self).__init__(None, tab_stop=False)
|
super(Label, self).__init__(None, tab_stop=False)
|
||||||
|
@ -271,7 +285,7 @@ class Confirm(Frame):
|
||||||
if current_selected_action == "KILL":
|
if current_selected_action == "KILL":
|
||||||
kill_module(PID_NAME_DICO[int(current_selected_value)], current_selected_value)
|
kill_module(PID_NAME_DICO[int(current_selected_value)], current_selected_value)
|
||||||
else:
|
else:
|
||||||
count = int(current_selected_amount)
|
count = int(current_selected_amount) #Number of queue to start
|
||||||
if current_selected_queue in ["running", "idle"]:
|
if current_selected_queue in ["running", "idle"]:
|
||||||
restart_module(PID_NAME_DICO[int(current_selected_value)], count)
|
restart_module(PID_NAME_DICO[int(current_selected_value)], count)
|
||||||
else:
|
else:
|
||||||
|
@ -392,13 +406,12 @@ class Show_paste(Frame):
|
||||||
title="Show current paste",
|
title="Show current paste",
|
||||||
reduce_cpu=True)
|
reduce_cpu=True)
|
||||||
|
|
||||||
# Create the form for displaying the list of contacts.
|
|
||||||
layout = Layout([100], fill_frame=True)
|
layout = Layout([100], fill_frame=True)
|
||||||
self.layout = layout
|
self.layout = layout
|
||||||
self.add_layout(layout)
|
self.add_layout(layout)
|
||||||
|
|
||||||
self.label_list = []
|
self.label_list = []
|
||||||
self.num_label = 42
|
self.num_label = 42 # Number of line available for displaying the paste
|
||||||
for i in range(self.num_label):
|
for i in range(self.num_label):
|
||||||
self.label_list += [Label("THE PASTE CONTENT " + str(i))]
|
self.label_list += [Label("THE PASTE CONTENT " + str(i))]
|
||||||
layout.add_widget(self.label_list[i])
|
layout.add_widget(self.label_list[i])
|
||||||
|
@ -426,19 +439,19 @@ class Show_paste(Frame):
|
||||||
return
|
return
|
||||||
|
|
||||||
paste = Paste.Paste(COMPLETE_PASTE_PATH_PER_PID[current_selected_value])
|
paste = Paste.Paste(COMPLETE_PASTE_PATH_PER_PID[current_selected_value])
|
||||||
old_content = paste.get_p_content()[0:4000]
|
old_content = paste.get_p_content()[0:4000] # Limit number of char to be displayed
|
||||||
|
|
||||||
#Replace unprintable char by ?
|
#Replace unprintable char by ?
|
||||||
content = ""
|
content = ""
|
||||||
for i, c in enumerate(old_content):
|
for i, c in enumerate(old_content):
|
||||||
if ord(c) > 127:
|
if ord(c) > 127: # Used to avoid printing unprintable char
|
||||||
content += '?'
|
content += '?'
|
||||||
elif c == "\t":
|
elif c == "\t": # Replace tab by 4 spaces
|
||||||
content += " "
|
content += " "
|
||||||
else:
|
else:
|
||||||
content += c
|
content += c
|
||||||
|
|
||||||
#Print in the correct label
|
#Print in the correct label, END or more
|
||||||
to_print = ""
|
to_print = ""
|
||||||
i = 0
|
i = 0
|
||||||
for line in content.split("\n"):
|
for line in content.split("\n"):
|
||||||
|
@ -448,13 +461,13 @@ class Show_paste(Frame):
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
if i > self.num_label - 2:
|
if i > self.num_label - 2:
|
||||||
self.label_list[i]._text = "..."
|
self.label_list[i]._text = "- ALL PASTE NOT DISPLAYED -"
|
||||||
i += 1
|
i += 1
|
||||||
else:
|
else:
|
||||||
self.label_list[i]._text = "- END -"
|
self.label_list[i]._text = "- END of PASTE -"
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
while i<self.num_label:
|
while i<self.num_label: #Clear out remaining lines
|
||||||
self.label_list[i]._text = ""
|
self.label_list[i]._text = ""
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue