blob: a3f19ddafc7a0c3939b9f629c3116d128a3a91e9 [file] [log] [blame]
Andrew Geisslerd159c7f2021-09-02 21:05:58 -05001#
2# SPDX-License-Identifier: GPL-2.0-only
3#
4
5import logging
6import bb.asyncrpc
7
8logger = logging.getLogger("BitBake.PRserv")
9
10class 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 async def is_readonly(self):
36 response = await self.send_message(
37 {'is-readonly': {}}
38 )
39 if response:
40 return response['readonly']
41
42class PRClient(bb.asyncrpc.Client):
43 def __init__(self):
44 super().__init__()
45 self._add_methods('getPR', 'importone', 'export', 'is_readonly')
46
47 def _get_async_client(self):
48 return PRAsyncClient()