cli: helper method to retrieve profile's jid:

rel 369
This commit is contained in:
Goffi 2022-07-10 16:15:09 +02:00
commit e84436adfd

View file

@ -697,7 +697,10 @@ class LiberviaCli:
await self.bridge.bridgeConnect()
except Exception as e:
if isinstance(e, exceptions.BridgeExceptionNoService):
print(_("Can't connect to SàT backend, are you sure it's launched ?"))
print(
_("Can't connect to Libervia backend, are you sure that it's "
"launched ?")
)
self.quit(C.EXIT_BACKEND_NOT_FOUND, raise_exc=False)
elif isinstance(e, exceptions.BridgeInitError):
print(_("Can't init bridge"))
@ -968,6 +971,13 @@ class LiberviaCli:
return f"{_jid.bare}/{main_resource}"
return param_jid
async def get_profile_jid(self):
"""Retrieve current profile bare JID if possible"""
full_jid = await self.bridge.asyncGetParamA(
"JabberID", "Connection", profile_key=self.profile
)
return full_jid.rsplit("/", 1)[0]
class CommandBase(object):