comparison 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
comparison
equal deleted inserted replaced
4192:1d24ff583794 4193:730f542e4ad0
397 if errback is None: 397 if errback is None:
398 d.addErrback(self._generic_errback) 398 d.addErrback(self._generic_errback)
399 else: 399 else:
400 d.addErrback(self._errback, ori_errback=errback) 400 d.addErrback(self._errback, ori_errback=errback)
401 401
402 def init_pre_script(self, callback=None, errback=None):
403 d = self.root.callRemote("init_pre_script")
404 if callback is not None:
405 d.addCallback(lambda __: callback())
406 if errback is None:
407 d.addErrback(self._generic_errback)
408 else:
409 d.addErrback(self._errback, ori_errback=errback)
410
402 def is_connected(self, profile_key="@DEFAULT@", callback=None, errback=None): 411 def is_connected(self, profile_key="@DEFAULT@", callback=None, errback=None):
403 d = self.root.callRemote("is_connected", profile_key) 412 d = self.root.callRemote("is_connected", profile_key)
404 if callback is not None: 413 if callback is not None:
405 d.addCallback(callback) 414 d.addCallback(callback)
406 if errback is None: 415 if errback is None:
953 def image_resize(self, image_path, width, height): 962 def image_resize(self, image_path, width, height):
954 d = self.root.callRemote("image_resize", image_path, width, height) 963 d = self.root.callRemote("image_resize", image_path, width, height)
955 d.addErrback(self._errback) 964 d.addErrback(self._errback)
956 return d.asFuture(asyncio.get_event_loop()) 965 return d.asFuture(asyncio.get_event_loop())
957 966
967 def init_pre_script(self):
968 d = self.root.callRemote("init_pre_script")
969 d.addErrback(self._errback)
970 return d.asFuture(asyncio.get_event_loop())
971
958 def is_connected(self, profile_key="@DEFAULT@"): 972 def is_connected(self, profile_key="@DEFAULT@"):
959 d = self.root.callRemote("is_connected", profile_key) 973 d = self.root.callRemote("is_connected", profile_key)
960 d.addErrback(self._errback) 974 d.addErrback(self._errback)
961 return d.asFuture(asyncio.get_event_loop()) 975 return d.asFuture(asyncio.get_event_loop())
962 976