def console_output(self, targets): pidfiles_and_ports = ReportingServerManager.get_current_server_pidfiles_and_ports() if not pidfiles_and_ports: return ['No server found.'] # There should only be one pidfile, but in case there are many, we kill them all here. for pidfile, port in pidfiles_and_ports: with open(pidfile, 'r') as infile: pidstr = infile.read() try: os.unlink(pidfile) pid = int(pidstr) os.kill(pid, signal.SIGKILL) return ['Killed server with pid %d at http://localhost:%d' % (pid, port)] except (ValueError, OSError): return []