Mercurial > libervia-backend
comparison sat/core/sat_main.py @ 3989:f5ba7594cced
core (main): log Exception when `bridge_pi` fails
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 24 Nov 2022 12:25:04 +0100 |
parents | 7af29260ecb8 |
children | 7bf7677b893d |
comparison
equal
deleted
inserted
replaced
3988:760f563b1243 | 3989:f5ba7594cced |
---|---|
93 sys.exit(1) | 93 sys.exit(1) |
94 log.info(f"using {bridge_name} bridge") | 94 log.info(f"using {bridge_name} bridge") |
95 try: | 95 try: |
96 self.bridge = bridge_module.Bridge() | 96 self.bridge = bridge_module.Bridge() |
97 except exceptions.BridgeInitError: | 97 except exceptions.BridgeInitError: |
98 log.error("Bridge can't be initialised, can't start Libervia Backend") | 98 log.exception("Bridge can't be initialised, can't start Libervia Backend") |
99 sys.exit(1) | 99 sys.exit(1) |
100 | 100 |
101 defer.ensureDeferred(self._postInit()) | 101 defer.ensureDeferred(self._post_init()) |
102 | 102 |
103 @property | 103 @property |
104 def version(self): | 104 def version(self): |
105 """Return the short version of Libervia""" | 105 """Return the short version of Libervia""" |
106 return C.APP_VERSION | 106 return C.APP_VERSION |
126 | 126 |
127 @property | 127 @property |
128 def bridge_name(self): | 128 def bridge_name(self): |
129 return os.path.splitext(os.path.basename(self.bridge.__file__))[0] | 129 return os.path.splitext(os.path.basename(self.bridge.__file__))[0] |
130 | 130 |
131 async def _postInit(self): | 131 async def _post_init(self): |
132 try: | 132 try: |
133 bridge_pi = self.bridge.postInit | 133 bridge_pi = self.bridge.postInit |
134 except AttributeError: | 134 except AttributeError: |
135 pass | 135 pass |
136 else: | 136 else: |
137 await bridge_pi() | 137 try: |
138 await bridge_pi() | |
139 except Exception: | |
140 log.exception("Could not initialize bridge") | |
141 # because init is not complete at this stage, we use callLater | |
142 reactor.callLater(0, self.stop) | |
143 return | |
138 | 144 |
139 self.bridge.register_method("getReady", lambda: self.initialised) | 145 self.bridge.register_method("getReady", lambda: self.initialised) |
140 self.bridge.register_method("getVersion", lambda: self.full_version) | 146 self.bridge.register_method("getVersion", lambda: self.full_version) |
141 self.bridge.register_method("getFeatures", self.getFeatures) | 147 self.bridge.register_method("getFeatures", self.getFeatures) |
142 self.bridge.register_method("profileNameGet", self.memory.getProfileName) | 148 self.bridge.register_method("profileNameGet", self.memory.getProfileName) |