Fixed screen bug by adding an input before starting asciimatics + improved path localisation in the logs from modules

This commit is contained in:
Mokaddem 2017-02-14 17:21:52 +01:00
parent d520c45a15
commit 444f6071b7
2 changed files with 20 additions and 5 deletions

View file

@ -158,10 +158,15 @@ class Process(object):
try: try:
if ".gz" in message: if ".gz" in message:
path = message.split(".")[-2].split("/")[-1] path = message.split(".")[-2].split("/")[-1]
#find start of path with AIL_HOME
index_s = message.find(os.environ['AIL_HOME'])
#Stop when .gz
index_e = message.find(".gz")+3
complete_path = message[index_s:index_e]
else: else:
path = "?" path = "?"
value = str(timestamp) + ", " + path value = str(timestamp) + ", " + path
complete_path = os.environ['AIL_HOME'] + "/PASTES/" + path
self.r_temp.set("MODULE_"+self.subscriber_name + "_" + str(self.moduleNum), value) self.r_temp.set("MODULE_"+self.subscriber_name + "_" + str(self.moduleNum), value)
self.r_temp.set("MODULE_"+self.subscriber_name + "_" + str(self.moduleNum) + "_PATH", complete_path) self.r_temp.set("MODULE_"+self.subscriber_name + "_" + str(self.moduleNum) + "_PATH", complete_path)
self.r_temp.sadd("MODULE_TYPE_"+self.subscriber_name, str(self.moduleNum)) self.r_temp.sadd("MODULE_TYPE_"+self.subscriber_name, str(self.moduleNum))
@ -171,7 +176,7 @@ class Process(object):
path = "?" path = "?"
value = str(timestamp) + ", " + path value = str(timestamp) + ", " + path
self.r_temp.set("MODULE_"+self.subscriber_name + "_" + str(self.moduleNum), value) self.r_temp.set("MODULE_"+self.subscriber_name + "_" + str(self.moduleNum), value)
self.r_temp.set("MODULE_"+self.subscriber_name + "_" + str(self.moduleNum) + "_PATH", complete_path) self.r_temp.set("MODULE_"+self.subscriber_name + "_" + str(self.moduleNum) + "_PATH", "?")
self.r_temp.sadd("MODULE_TYPE_"+self.subscriber_name, str(self.moduleNum)) self.r_temp.sadd("MODULE_TYPE_"+self.subscriber_name, str(self.moduleNum))
return message return message

View file

@ -111,6 +111,8 @@ class CListBox(ListBox):
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":
return event
current_selected_value = self.value current_selected_value = self.value
current_selected_queue = self.queue_name current_selected_queue = self.queue_name
self._frame.save() self._frame.save()
@ -229,7 +231,7 @@ class Confirm(Frame):
def __init__(self, screen): def __init__(self, screen):
super(Confirm, self).__init__(screen, super(Confirm, self).__init__(screen,
screen.height * 1 // 8, screen.height * 1 // 8,
screen.width * 1 // 4, screen.width * 1 // 3,
hover_focus=True, hover_focus=True,
on_load=self._setValue, on_load=self._setValue,
title="Confirm action", title="Confirm action",
@ -305,7 +307,8 @@ class Action_choice(Frame):
layout2 = Layout([1,1,1,1]) layout2 = Layout([1,1,1,1])
self.add_layout(layout2) self.add_layout(layout2)
layout2.add_widget(Button("Cancel", self._cancel), 0) layout2.add_widget(Button("Cancel", self._cancel), 0)
layout2.add_widget(Button("Show current paste", self._showpaste), 1) self._ShowPasteBtn = Button("Show current paste", self._showpaste)
layout2.add_widget(self._ShowPasteBtn, 1)
self._killBtn = Button("KILL", self._kill) self._killBtn = Button("KILL", self._kill)
layout2.add_widget(self._killBtn, 2) layout2.add_widget(self._killBtn, 2)
layout2.add_widget(Button("START", self._start), 3) layout2.add_widget(Button("START", self._start), 3)
@ -351,12 +354,14 @@ class Action_choice(Frame):
def _setValue(self): def _setValue(self):
self._killBtn.disabled = False self._killBtn.disabled = False
self._ShowPasteBtn.disabled = False
global current_selected_value, current_selected_queue global current_selected_value, current_selected_queue
if current_selected_queue in ["running", "idle"]: if current_selected_queue in ["running", "idle"]:
modulename = PID_NAME_DICO[int(current_selected_value)] modulename = PID_NAME_DICO[int(current_selected_value)]
pid = current_selected_value pid = current_selected_value
else: else:
self._killBtn.disabled = True self._killBtn.disabled = True
self._ShowPasteBtn.disabled = True
modulename = current_selected_value modulename = current_selected_value
pid = "" pid = ""
self.label._text = self.label._text.format(modulename, pid) self.label._text = self.label._text.format(modulename, pid)
@ -430,7 +435,8 @@ class Show_paste(Frame):
except OSError as e: except OSError as e:
self.label_list[0]._text = "Error during parsing the filepath. Please, check manually" self.label_list[0]._text = "Error during parsing the filepath. Please, check manually"
for i in range(1,self.num_label): self.label_list[1]._text = COMPLETE_PASTE_PATH_PER_PID[current_selected_value]
for i in range(2,self.num_label):
self.label_list[i]._text = "" self.label_list[i]._text = ""
except Exception as e: except Exception as e:
@ -744,6 +750,10 @@ if __name__ == "__main__":
TABLES_TITLES["notRunning"] = format_string([([" Action", "Queue", "State"],0)], TABLES_PADDING["notRunning"])[0][0] TABLES_TITLES["notRunning"] = format_string([([" Action", "Queue", "State"],0)], TABLES_PADDING["notRunning"])[0][0]
TABLES_TITLES["logs"] = format_string([(["Time", "Module", "PID", "Info"],0)], TABLES_PADDING["logs"])[0][0] TABLES_TITLES["logs"] = format_string([(["Time", "Module", "PID", "Info"],0)], TABLES_PADDING["logs"])[0][0]
try:
input("Press < ENTER > to launch the manager...")
except SyntaxError:
pass
while True: while True:
Screen.wrapper(demo) Screen.wrapper(demo)