Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion ptop/interfaces/GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down