From 444f6071b72f00304bbbff2dc6e97d9b458261a5 Mon Sep 17 00:00:00 2001 From: Mokaddem Date: Tue, 14 Feb 2017 17:21:52 +0100 Subject: [PATCH] Fixed screen bug by adding an input before starting asciimatics + improved path localisation in the logs from modules --- bin/Helper.py | 9 +++++++-- bin/ModulesInformationV2.py | 16 +++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/bin/Helper.py b/bin/Helper.py index 8d9caf3b..7d3abcbd 100755 --- a/bin/Helper.py +++ b/bin/Helper.py @@ -158,10 +158,15 @@ class Process(object): try: if ".gz" in message: 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: 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) + "_PATH", complete_path) self.r_temp.sadd("MODULE_TYPE_"+self.subscriber_name, str(self.moduleNum)) @@ -171,7 +176,7 @@ class Process(object): 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) + "_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)) return message diff --git a/bin/ModulesInformationV2.py b/bin/ModulesInformationV2.py index 930d0075..c41700ba 100755 --- a/bin/ModulesInformationV2.py +++ b/bin/ModulesInformationV2.py @@ -111,6 +111,8 @@ class CListBox(ListBox): self.value = self._options[self._line][1] elif len(self._options) > 0 and event.key_code == ord(' '): global current_selected_value, current_selected_queue + if self.queue_name == "logs": + return event current_selected_value = self.value current_selected_queue = self.queue_name self._frame.save() @@ -229,7 +231,7 @@ class Confirm(Frame): def __init__(self, screen): super(Confirm, self).__init__(screen, screen.height * 1 // 8, - screen.width * 1 // 4, + screen.width * 1 // 3, hover_focus=True, on_load=self._setValue, title="Confirm action", @@ -305,7 +307,8 @@ class Action_choice(Frame): layout2 = Layout([1,1,1,1]) self.add_layout(layout2) 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) layout2.add_widget(self._killBtn, 2) layout2.add_widget(Button("START", self._start), 3) @@ -351,12 +354,14 @@ class Action_choice(Frame): def _setValue(self): self._killBtn.disabled = False + self._ShowPasteBtn.disabled = False global current_selected_value, current_selected_queue if current_selected_queue in ["running", "idle"]: modulename = PID_NAME_DICO[int(current_selected_value)] pid = current_selected_value else: self._killBtn.disabled = True + self._ShowPasteBtn.disabled = True modulename = current_selected_value pid = "" self.label._text = self.label._text.format(modulename, pid) @@ -430,7 +435,8 @@ class Show_paste(Frame): except OSError as e: 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 = "" 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["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: Screen.wrapper(demo)