From 9133ecb527756f4fc8f3461002eecfc4c4f45aaa Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 8 Oct 2012 14:47:35 -0400 Subject: [PATCH] client: add AssuanClient.send_fds() and .receive_fds(). These are thin wrappers around the `common` functions, which hide the existence of AssuanClient.socket and make the logging more consistent with other client send/receive logging. --- pyassuan/client.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pyassuan/client.py b/pyassuan/client.py index 2555ebc..8413633 100644 --- a/pyassuan/client.py +++ b/pyassuan/client.py @@ -170,3 +170,21 @@ class AssuanClient (object): self._write_request(request=request) if response: return self.get_responses(requests=requests, expect=expect) + + def send_fds(self, fds): + """Send a file descriptor over a Unix socket. + """ + msg = '# descriptors in flight: {}\n'.format(fds) + self.logger.info('C: {}'.format(msg.rstrip('\n'))) + msg = msg.encode('ascii') + return _common.send_fds( + socket=self.socket, msg=msg, fds=fds, logger=None) + + def receive_fds(self, msglen=200, maxfds=10): + """Receive file descriptors over a Unix socket. + """ + msg,fds = _common.receive_fds( + socket=self.socket, msglen=msglen, maxfds=maxfds, logger=None) + msg = str(msg, 'utf-8') + self.logger.info('S: {}'.format(msg.rstrip('\n'))) + return fds -- 2.26.2