def kill(self): if sublime.platform() == "windows": kill_process = subprocess.Popen(['C:\\Windows\\system32\\taskkill.exe', '/F', '/T', '/PID', str(self.pid)], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) kill_process.communicate() else: os.killpg(self.pid, signal.SIGTERM) ProcessCache.remove(self)
def run(self, command): with Dir.cd(self.working_dir): self.process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=self.path, shell=True, preexec_fn=self._preexec_val()) self.pid = self.process.pid self.last_command = command.rstrip() ProcessCache.add(self) return self
def work(self): ProcessCache.refresh() if ProcessCache.empty(): self.status_message("There are no running tasks") else: self.append_processes_to_output_view() ProcessCache.kill_all() self.append_to_output_view("\nAll running tasks killed!\n")
def work(self): ProcessCache.refresh() if ProcessCache.empty(): self.status_message("There are no running tasks") else: self.procs = ProcessCache.get() quick_panel_list = [[process.last_command, process.working_dir, 'PID: %d' % process.pid] for process in self.procs] self.show_quick_panel(quick_panel_list, self.kill_process, font=0)
def work(self): ProcessCache.refresh() if ProcessCache.empty(): self.status_message("There are no running tasks") else: self.procs = ProcessCache.get() quick_panel_list = [[ process.last_command, process.working_dir, 'PID: %d' % process.pid ] for process in self.procs] self.show_quick_panel(quick_panel_list, self.kill_process, font=0)
def update(self): if ProcessCache.empty(): return self.erase() status_bar_tasks = self.settings.get('status_bar_tasks', False) if status_bar_tasks: task_names = set([process.get_task_name() for process in ProcessCache.get()]) if status_bar_tasks != True: if not isinstance(status_bar_tasks, list): status_bar_tasks = [status_bar_tasks] task_names = task_names.intersection(set(status_bar_tasks)) if task_names: defer_sync(lambda: self.set(', '.join(task_names)))
def load_process_cache(): for process in ProcessCache.get_from_storage(): ProcessCache.add( CrossPlatformProcess(process['workding_dir'], process['last_command'], process['pid']) )
def append_processes_to_output_view(self): self.show_output_panel("\nFinishing the following running tasks:\n") ProcessCache.each(lambda process: self.append_to_output_view("$ %s # %s | PID: %d\n" % process.to_tuple()))
def terminate(self): if self.is_alive(): self.process.terminate() ProcessCache.remove(self)
def load_process_cache(): for process in ProcessCache.get_from_storage(): ProcessCache.add( CrossPlatformProcess(process['workding_dir'], process['last_command'], process['pid']))
def append_processes_to_output_view(self): self.show_output_panel("\nFinishing the following running tasks:\n") ProcessCache.each(lambda process: self.append_to_output_view( "$ %s # %s | PID: %d\n" % process.to_tuple()))