Mercurial > libervia-backend
diff libervia/frontends/bridge/pb.py @ 4193:730f542e4ad0
core: add new `init_script_path` option:
`init_script_path` option can be used in `[DEFAULTS]` to run a script at the end of
backend initialisation. A new `init_pre_script` method is used to wait for backend to
reach this stage (designed to be used mostly by CLI frontend), then the usual `ready_get`
method is finished once the script is finished.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 13 Dec 2023 22:00:22 +0100 |
parents | 02f0adc745c6 |
children | 0d7bb4df2343 |
line wrap: on
line diff
--- a/libervia/frontends/bridge/pb.py Tue Dec 12 12:17:15 2023 +0100 +++ b/libervia/frontends/bridge/pb.py Wed Dec 13 22:00:22 2023 +0100 @@ -399,6 +399,15 @@ else: d.addErrback(self._errback, ori_errback=errback) + def init_pre_script(self, callback=None, errback=None): + d = self.root.callRemote("init_pre_script") + if callback is not None: + d.addCallback(lambda __: callback()) + if errback is None: + d.addErrback(self._generic_errback) + else: + d.addErrback(self._errback, ori_errback=errback) + def is_connected(self, profile_key="@DEFAULT@", callback=None, errback=None): d = self.root.callRemote("is_connected", profile_key) if callback is not None: @@ -955,6 +964,11 @@ d.addErrback(self._errback) return d.asFuture(asyncio.get_event_loop()) + def init_pre_script(self): + d = self.root.callRemote("init_pre_script") + d.addErrback(self._errback) + return d.asFuture(asyncio.get_event_loop()) + def is_connected(self, profile_key="@DEFAULT@"): d = self.root.callRemote("is_connected", profile_key) d.addErrback(self._errback)