diff --git a/osbuild/api.py b/osbuild/api.py index f7e8aa06..7368a59a 100644 --- a/osbuild/api.py +++ b/osbuild/api.py @@ -51,7 +51,7 @@ class BaseAPI(abc.ABC): """The name of the API endpoint""" @abc.abstractmethod - def _message(self, msg: Dict, fds: jsoncomm.FdSet, sock: jsoncomm.Socket, addr: str): + def _message(self, msg: Dict, fds: jsoncomm.FdSet, sock: jsoncomm.Socket): """Called for a new incoming message The file descriptor set `fds` will be closed after the call. @@ -68,12 +68,12 @@ class BaseAPI(abc.ABC): def _dispatch(self, sock: jsoncomm.Socket): """Called when data is available on the socket""" - msg, fds, addr = sock.recv() + msg, fds, _ = sock.recv() if msg is None: # Peer closed the connection self.event_loop.remove_reader(sock) return - self._message(msg, fds, sock, addr) + self._message(msg, fds, sock) fds.close() def _accept(self, server): @@ -162,7 +162,7 @@ class API(BaseAPI): self._output_data.write(data) self.monitor.log(data) - def _setup_stdio(self, server, addr): + def _setup_stdio(self, server): with self._prepare_input() as stdin, \ self._prepare_output() as stdout: msg = {} @@ -174,11 +174,11 @@ class API(BaseAPI): fds.append(stdout.fileno()) msg['stderr'] = 2 - server.send(msg, fds=fds, destination=addr) + server.send(msg, fds=fds) - def _message(self, msg, fds, sock, addr): + def _message(self, msg, fds, sock): if msg["method"] == 'setup-stdio': - self._setup_stdio(sock, addr) + self._setup_stdio(sock) def _cleanup(self): if self._output_pipe: diff --git a/osbuild/remoteloop.py b/osbuild/remoteloop.py index 0306d891..c2d583bf 100644 --- a/osbuild/remoteloop.py +++ b/osbuild/remoteloop.py @@ -70,14 +70,14 @@ class LoopServer(api.BaseAPI): self.devs.append(lo) return lo.devname - def _message(self, msg, fds, sock, addr): + def _message(self, msg, fds, sock): fd = fds[msg["fd"]] dir_fd = fds[msg["dir_fd"]] offset = msg.get("offset") sizelimit = msg.get("sizelimit") devname = self._create_device(fd, dir_fd, offset, sizelimit) - sock.send({"devname": devname}, destination=addr) + sock.send({"devname": devname}) def _cleanup(self): for lo in self.devs: diff --git a/osbuild/sources.py b/osbuild/sources.py index 2adf9e5b..97f6a898 100644 --- a/osbuild/sources.py +++ b/osbuild/sources.py @@ -36,9 +36,9 @@ class SourcesServer(api.BaseAPI): except ValueError: return {"error": f"source returned malformed json: {r.stdout}"} - def _message(self, msg, fds, sock, addr): + def _message(self, msg, fds, sock): reply = self._run_source(msg["source"], msg["checksums"]) - sock.send(reply, destination=addr) + sock.send(reply) def get(source, checksums, api_path="/run/osbuild/api/sources"): diff --git a/test/mod/test_api.py b/test/mod/test_api.py index 014c5c59..004a5f62 100644 --- a/test/mod/test_api.py +++ b/test/mod/test_api.py @@ -23,12 +23,12 @@ class APITester(osbuild.api.BaseAPI): endpoint = "test-api" - def _message(self, msg, _fds, sock, addr): + def _message(self, msg, _fds, sock): self.messages += 1 if msg["method"] == "echo": msg["method"] = "reply" - sock.send(msg, destination=addr) + sock.send(msg) def _cleanup(self): self.clean = True