Mercurial > libervia-backend
comparison libervia/cli/cmd_pipe.py @ 4270:0d7bb4df2343
Reformatted code base using black.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 19 Jun 2024 18:44:57 +0200 |
parents | 47401850dec6 |
children |
comparison
equal
deleted
inserted
replaced
4269:64a85ce8be70 | 4270:0d7bb4df2343 |
---|---|
38 class PipeOut(base.CommandBase): | 38 class PipeOut(base.CommandBase): |
39 def __init__(self, host): | 39 def __init__(self, host): |
40 super(PipeOut, self).__init__(host, "out", help=_("send a pipe a stream")) | 40 super(PipeOut, self).__init__(host, "out", help=_("send a pipe a stream")) |
41 | 41 |
42 def add_parser_options(self): | 42 def add_parser_options(self): |
43 self.parser.add_argument( | 43 self.parser.add_argument("jid", help=_("the destination jid")) |
44 "jid", help=_("the destination jid") | |
45 ) | |
46 | 44 |
47 async def start(self): | 45 async def start(self): |
48 """ Create named pipe, and send stdin to it """ | 46 """Create named pipe, and send stdin to it""" |
49 try: | 47 try: |
50 port = await self.host.bridge.stream_out( | 48 port = await self.host.bridge.stream_out( |
51 await self.host.get_full_jid(self.args.jid), | 49 await self.host.get_full_jid(self.args.jid), |
52 self.profile, | 50 self.profile, |
53 ) | 51 ) |
131 if not self.bare_jids or from_jid.bare in self.bare_jids: | 129 if not self.bare_jids or from_jid.bare in self.bare_jids: |
132 host, port = "localhost", START_PORT | 130 host, port = "localhost", START_PORT |
133 while True: | 131 while True: |
134 try: | 132 try: |
135 server = await asyncio.start_server( | 133 server = await asyncio.start_server( |
136 partial(handle_stream_in, host=self.host), host, port) | 134 partial(handle_stream_in, host=self.host), host, port |
135 ) | |
137 except socket.error as e: | 136 except socket.error as e: |
138 if e.errno == errno.EADDRINUSE: | 137 if e.errno == errno.EADDRINUSE: |
139 port += 1 | 138 port += 1 |
140 else: | 139 else: |
141 raise e | 140 raise e |