jp: jp asyncio port:

/!\ this commit is huge. Jp is temporarily not working with `dbus` bridge /!\

This patch implements the port of jp to asyncio, so it is now correctly using the bridge
asynchronously, and it can be used with bridges like `pb`. This also simplify the code,
notably for things which were previously implemented with many callbacks (like pagination
with RSM).

During the process, some behaviours have been modified/fixed, in jp and backends, check
diff for details.
This commit is contained in:
Goffi 2019-09-25 08:56:41 +02:00
commit 76aadbb3fb

View file

@ -76,8 +76,7 @@ class CommandProtocol(protocol.ProcessProtocol):
def processEnded(self, reason):
data = b''.join(self.data)
if (reason.value.exitCode == 0):
log.debug(_('{name!r} command succeed').format(
name=self.command_name.decode('utf-8', 'ignore')))
log.debug(_(f'{self.command_name!r} command succeed'))
# we don't use "replace" on purpose, we want an exception if decoding
# is not working properly
self._deferred.callback(data)
@ -106,7 +105,7 @@ class CommandProtocol(protocol.ProcessProtocol):
- stdin(unicode, None): data to push to standard input
- verbose(bool): if True stdout and stderr will be logged
other keyword arguments will be used in reactor.spawnProcess
@return ((D)): stdout in case of success
@return ((D)bytes): stdout in case of success
@raise RuntimeError: command returned a non zero status
stdin and stdout will be given as arguments
@ -115,8 +114,6 @@ class CommandProtocol(protocol.ProcessProtocol):
if stdin is not None:
stdin = stdin.encode('utf-8')
verbose = kwargs.pop('verbose', False)
if 'path' in kwargs:
kwargs['path'] = kwargs['path'].encode('utf-8')
args = [a.encode('utf-8') for a in args]
kwargs = {k:v.encode('utf-8') for k,v in list(kwargs.items())}
d = defer.Deferred()