From b4f4aeac51515203c036b9ddc9007cf4556b8ea4 Mon Sep 17 00:00:00 2001 From: iMshivji Date: Mon, 12 Nov 2018 14:11:19 +0530 Subject: [PATCH 1/2] Add files via upload --- ptop/interfaces/GUI.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ptop/interfaces/GUI.py b/ptop/interfaces/GUI.py index 83a7f5f..fe19a98 100644 --- a/ptop/interfaces/GUI.py +++ b/ptop/interfaces/GUI.py @@ -99,6 +99,7 @@ def __init__(self,*args,**kwargs): "^K" : self._kill_process, "^Q" : self._quit, "^R" : self._reset, + "^S" : self._restart_process, "^H" : self._do_process_filtering_work, "^L" : self._show_detailed_process_info, "^F" : self._do_process_filtering_work @@ -158,6 +159,22 @@ def _reset(self,*args,**kwargs): PROCESS_RELEVANCE_SORT = True self._filtering_flag = False +#ISSUE #45 iMshivji + def _restart_process(self,*args,**kwargs): + self._logger.info("Restarting the selected process") + pid_to_restart = self._get_selected_process_pid() + self._kill_process(self,args,*kwargs) + try: + process_name=psutil.Process(int(pid_to_restart)).name() + subprocess.Popen(process_name) + except: + try: + process_name=psutil.Process(int(pid_to_restart)).exe() + subprocess.Popen(process_name) + except: + pass + + def _do_process_filtering_work(self,*args,**kwargs): ''' Dynamically instantiate a process filtering box used @@ -585,7 +602,7 @@ def draw(self): self._logger.info("Actions box drawn, x1 {0} y1 {1}".format(ACTIONS_WIDGET_REL_X, ACTIONS_WIDGET_REL_Y) ) - self.actions.value = "^K:Kill\t\t^N:Memory Sort\t\t^T:Time Sort\t\t^R:Reset\t\tg:Top\t\t^Q:Quit\t\t^F:Filter\t\t^L:Info" + self.actions.value = "^K:Kill\t\t^N:Memory Sort\t\t^T:Time Sort\t\t^R:Reset\t\tg:Top\t\t^Q:Quit\t\t^F:Filter\t\t^L:Info\t\t^S:Restart" self.actions.display() self.actions.editable = False From fede2f988191a699f5b6ef32fa07115e197d4f0c Mon Sep 17 00:00:00 2001 From: iMshivji Date: Mon, 12 Nov 2018 14:28:26 +0530 Subject: [PATCH 2/2] Restart option for processes Added ^S for restart for processes like web browsers, text editors,....