def process_line(l): args = l.split() cmd = args[0] if cmd == 'status': return core.status() elif cmd == 'server': channel = args[1] addr = args[2] port = int(args[3]) ret = core.server(channel, (addr, port)) core.save() return ret elif cmd == 'client': channel = args[1] try: port = int(args[2]) except IndexError: port = None ret = core.client(channel, port) core.save() return ret elif cmd == 'kill': id = int(args[1]) ret = core.kill(id) core.save() return ret assert False
def kill(): id_ = int(request.args.get('id')) ret = core.kill(id_) if ret: return json.dumps({'code': 'failure', 'message': ret}) return json.dumps({'code': 'success'})
def process_line(line: bytes): line: str = line.decode() args: Sequence[str] = line.split() cmd = args[0] if cmd == 'status': return core.status() elif cmd == 'server': channel = args[1] addr = args[2] port = int(args[3]) ret = core.server(channel, (addr, port)) core.save() return ret elif cmd == 'client': channel = args[1] try: port = int(args[2]) except IndexError: port = None ret = core.client(channel, port) core.save() return ret elif cmd == 'kill': pid = int(args[1]) ret = core.kill(pid) core.save() return ret assert False