Merge pull request #3958 from BigRoy/fusion_backwards_compatibility

This commit is contained in:
Milan Kolar 2022-10-20 11:31:19 +02:00 committed by GitHub
commit d283dce334
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -44,11 +44,26 @@ INVENTORY_PATH = os.path.join(PLUGINS_DIR, "inventory")
class FusionLogHandler(logging.Handler):
# Keep a reference to fusion's Print function (Remote Object)
_print = getattr(sys.modules["__main__"], "fusion").Print
_print = None
@property
def print(self):
if self._print is not None:
# Use cached
return self._print
_print = getattr(sys.modules["__main__"], "fusion").Print
if _print is None:
# Backwards compatibility: Print method on Fusion instance was
# added around Fusion 17.4 and wasn't available on PyRemote Object
# before
_print = get_current_comp().Print
self._print = _print
return _print
def emit(self, record):
entry = self.format(record)
self._print(entry)
self.print(entry)
def install():