Mercurial > libervia-backend
comparison sat/core/sat_main.py @ 3539:60d3861e5996
bridge (dbus): use Tx DBus for backend part of D-Bus bridge:
Due to recent SQLAlchemy integration, Libervia is now using AsyncIO loop exclusively as
main loop, thus GLib's one can't be used anymore (event if it could be in a separate
thread).
Furthermore Python-DBus is known to have design flaws mentioned even in the official
documentation.
Tx DBus is now used to replace Python-DBus, but only for the backend for now, as it will
need some work on the frontend before we can get completely rid of it.
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 03 Jun 2021 15:21:43 +0200 |
parents | f9a5b810f14d |
children | 888109774673 |
comparison
equal
deleted
inserted
replaced
3538:c605a0d6506f | 3539:60d3861e5996 |
---|---|
79 "disco#info": xmpp.NS_DISCO_INFO, | 79 "disco#info": xmpp.NS_DISCO_INFO, |
80 } | 80 } |
81 | 81 |
82 self.memory = memory.Memory(self) | 82 self.memory = memory.Memory(self) |
83 | 83 |
84 # trigger are used to change SàT behaviour | 84 # trigger are used to change Libervia behaviour |
85 self.trigger = ( | 85 self.trigger = ( |
86 trigger.TriggerManager() | 86 trigger.TriggerManager() |
87 ) | 87 ) |
88 | 88 |
89 bridge_name = self.memory.getConfig("", "bridge", "dbus") | 89 bridge_name = self.memory.getConfig("", "bridge", "dbus") |
90 | 90 |
91 bridge_module = dynamic_import.bridge(bridge_name) | 91 bridge_module = dynamic_import.bridge(bridge_name) |
92 if bridge_module is None: | 92 if bridge_module is None: |
93 log.error("Can't find bridge module of name {}".format(bridge_name)) | 93 log.error(f"Can't find bridge module of name {bridge_name}") |
94 sys.exit(1) | 94 sys.exit(1) |
95 log.info("using {} bridge".format(bridge_name)) | 95 log.info(f"using {bridge_name} bridge") |
96 try: | 96 try: |
97 self.bridge = bridge_module.Bridge() | 97 self.bridge = bridge_module.Bridge() |
98 except exceptions.BridgeInitError: | 98 except exceptions.BridgeInitError: |
99 log.error("Bridge can't be initialised, can't start SàT core") | 99 log.error("Bridge can't be initialised, can't start Libervia Backend") |
100 sys.exit(1) | 100 sys.exit(1) |
101 | |
102 defer.ensureDeferred(self._postInit()) | |
103 | |
104 @property | |
105 def version(self): | |
106 """Return the short version of Libervia""" | |
107 return C.APP_VERSION | |
108 | |
109 @property | |
110 def full_version(self): | |
111 """Return the full version of Libervia | |
112 | |
113 In developement mode, release name and extra data are returned too | |
114 """ | |
115 version = self.version | |
116 if version[-1] == "D": | |
117 # we are in debug version, we add extra data | |
118 try: | |
119 return self._version_cache | |
120 except AttributeError: | |
121 self._version_cache = "{} « {} » ({})".format( | |
122 version, C.APP_RELEASE_NAME, utils.getRepositoryData(sat) | |
123 ) | |
124 return self._version_cache | |
125 else: | |
126 return version | |
127 | |
128 @property | |
129 def bridge_name(self): | |
130 return os.path.splitext(os.path.basename(self.bridge.__file__))[0] | |
131 | |
132 async def _postInit(self): | |
133 try: | |
134 bridge_pi = self.bridge.postInit | |
135 except AttributeError: | |
136 pass | |
137 else: | |
138 await bridge_pi() | |
139 | |
101 self.bridge.register_method("getReady", lambda: self.initialised) | 140 self.bridge.register_method("getReady", lambda: self.initialised) |
102 self.bridge.register_method("getVersion", lambda: self.full_version) | 141 self.bridge.register_method("getVersion", lambda: self.full_version) |
103 self.bridge.register_method("getFeatures", self.getFeatures) | 142 self.bridge.register_method("getFeatures", self.getFeatures) |
104 self.bridge.register_method("profileNameGet", self.memory.getProfileName) | 143 self.bridge.register_method("profileNameGet", self.memory.getProfileName) |
105 self.bridge.register_method("profilesListGet", self.memory.getProfilesList) | 144 self.bridge.register_method("profilesListGet", self.memory.getProfilesList) |
174 self.bridge.register_method("namespacesGet", self.getNamespaces) | 213 self.bridge.register_method("namespacesGet", self.getNamespaces) |
175 self.bridge.register_method("imageCheck", self._imageCheck) | 214 self.bridge.register_method("imageCheck", self._imageCheck) |
176 self.bridge.register_method("imageResize", self._imageResize) | 215 self.bridge.register_method("imageResize", self._imageResize) |
177 self.bridge.register_method("imageGeneratePreview", self._imageGeneratePreview) | 216 self.bridge.register_method("imageGeneratePreview", self._imageGeneratePreview) |
178 self.bridge.register_method("imageConvert", self._imageConvert) | 217 self.bridge.register_method("imageConvert", self._imageConvert) |
179 defer.ensureDeferred(self._postInit()) | 218 |
180 | 219 |
181 @property | |
182 def version(self): | |
183 """Return the short version of SàT""" | |
184 return C.APP_VERSION | |
185 | |
186 @property | |
187 def full_version(self): | |
188 """Return the full version of SàT | |
189 | |
190 In developement mode, release name and extra data are returned too | |
191 """ | |
192 version = self.version | |
193 if version[-1] == "D": | |
194 # we are in debug version, we add extra data | |
195 try: | |
196 return self._version_cache | |
197 except AttributeError: | |
198 self._version_cache = "{} « {} » ({})".format( | |
199 version, C.APP_RELEASE_NAME, utils.getRepositoryData(sat) | |
200 ) | |
201 return self._version_cache | |
202 else: | |
203 return version | |
204 | |
205 @property | |
206 def bridge_name(self): | |
207 return os.path.splitext(os.path.basename(self.bridge.__file__))[0] | |
208 | |
209 async def _postInit(self): | |
210 await self.memory.initialise() | 220 await self.memory.initialise() |
211 self.common_cache = cache.Cache(self, None) | 221 self.common_cache = cache.Cache(self, None) |
212 log.info(_("Memory initialised")) | 222 log.info(_("Memory initialised")) |
213 try: | 223 try: |
214 self._import_plugins() | 224 self._import_plugins() |