diff options
author | Paul Barker <pbarker@konsulko.com> | 2021-08-19 12:46:43 -0400 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-08-23 08:30:54 +0100 |
commit | fb3b05fe8da817967c9f90d4c4c0c1fee87c9f01 (patch) | |
tree | d6fe2fd8a3c3244932d2dbc393209ed638028855 /bitbake/lib/prserv/client.py | |
parent | 4df610473f21da79164ed01927103d13240d4c2a (diff) | |
download | poky-fb3b05fe8da817967c9f90d4c4c0c1fee87c9f01.tar.gz |
bitbake: prserv: Replace XML RPC with modern asyncrpc implementation
Update the prserv client and server classes to use the modern json and
asyncio based RPC system implemented by the asyncrpc module.
(Bitbake rev: 6a2b23e27bb61185b8afb382e20ce79f996d9183)
Signed-off-by: Paul Barker <pbarker@konsulko.com>
[updated for asyncrpc changes, client split to separate file]
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/prserv/client.py')
-rw-r--r-- | bitbake/lib/prserv/client.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/bitbake/lib/prserv/client.py b/bitbake/lib/prserv/client.py new file mode 100644 index 0000000000..285dce72f6 --- /dev/null +++ b/bitbake/lib/prserv/client.py | |||
@@ -0,0 +1,41 @@ | |||
1 | # | ||
2 | # SPDX-License-Identifier: GPL-2.0-only | ||
3 | # | ||
4 | |||
5 | import logging | ||
6 | import bb.asyncrpc | ||
7 | |||
8 | logger = logging.getLogger("BitBake.PRserv") | ||
9 | |||
10 | class PRAsyncClient(bb.asyncrpc.AsyncClient): | ||
11 | def __init__(self): | ||
12 | super().__init__('PRSERVICE', '1.0', logger) | ||
13 | |||
14 | async def getPR(self, version, pkgarch, checksum): | ||
15 | response = await self.send_message( | ||
16 | {'get-pr': {'version': version, 'pkgarch': pkgarch, 'checksum': checksum}} | ||
17 | ) | ||
18 | if response: | ||
19 | return response['value'] | ||
20 | |||
21 | async def importone(self, version, pkgarch, checksum, value): | ||
22 | response = await self.send_message( | ||
23 | {'import-one': {'version': version, 'pkgarch': pkgarch, 'checksum': checksum, 'value': value}} | ||
24 | ) | ||
25 | if response: | ||
26 | return response['value'] | ||
27 | |||
28 | async def export(self, version, pkgarch, checksum, colinfo): | ||
29 | response = await self.send_message( | ||
30 | {'export': {'version': version, 'pkgarch': pkgarch, 'checksum': checksum, 'colinfo': colinfo}} | ||
31 | ) | ||
32 | if response: | ||
33 | return (response['metainfo'], response['datainfo']) | ||
34 | |||
35 | class PRClient(bb.asyncrpc.Client): | ||
36 | def __init__(self): | ||
37 | super().__init__() | ||
38 | self._add_methods('getPR', 'importone', 'export') | ||
39 | |||
40 | def _get_async_client(self): | ||
41 | return PRAsyncClient() | ||