# HG changeset patch # User Goffi # Date 1663792439 -7200 # Node ID 6c93a18b6250616701dd5c45310fedb8a5d8faa6 # Parent 1e64f1ed3ebd5d978bb2046ec4fef5fb01838642 plugin XEP-0050: use coroutine + minor code readability improvments: rel 372 diff -r 1e64f1ed3ebd -r 6c93a18b6250 sat/plugins/plugin_xep_0050.py --- a/sat/plugins/plugin_xep_0050.py Wed Sep 21 22:32:36 2022 +0200 +++ b/sat/plugins/plugin_xep_0050.py Wed Sep 21 22:33:59 2022 +0200 @@ -88,19 +88,11 @@ self.label = label self.node = node self.features = [disco.DiscoFeature(feature) for feature in features] - ( - self.allowed_jids, - self.allowed_groups, - self.allowed_magics, - self.forbidden_jids, - self.forbidden_groups, - ) = ( - allowed_jids, - allowed_groups, - allowed_magics, - forbidden_jids, - forbidden_groups, - ) + self.allowed_jids = allowed_jids + self.allowed_groups = allowed_groups + self.allowed_magics = allowed_magics + self.forbidden_jids = forbidden_jids + self.forbidden_groups = forbidden_groups self.sessions = Sessions(timeout=timeout) @property @@ -624,12 +616,11 @@ def _run(self, service_jid_s="", node="", profile_key=C.PROF_KEY_NONE): client = self.host.getClient(profile_key) service_jid = jid.JID(service_jid_s) if service_jid_s else None - d = self.run(client, service_jid, node or None) + d = defer.ensureDeferred(self.run(client, service_jid, node or None)) d.addCallback(lambda xmlui: xmlui.toXml()) return d - @defer.inlineCallbacks - def run(self, client, service_jid=None, node=None): + async def run(self, client, service_jid=None, node=None): """Run an ad-hoc command @param service_jid(jid.JID, None): jid of the ad-hoc service @@ -643,16 +634,16 @@ session_id, session_data = self.requesting.newSession(profile=client.profile) session_data["jid"] = service_jid if node is None: - xmlui = yield self.listUI(client, service_jid) + xmlui = await self.listUI(client, service_jid) else: session_data["node"] = node - cb_data = yield self.requestingEntity( + cb_data = await self.requestingEntity( {"session_id": session_id}, client.profile ) xmlui = cb_data["xmlui"] xmlui.session_id = session_id - defer.returnValue(xmlui) + return xmlui def list(self, client, to_jid): """Request available commands