comparison sat_frontends/jp/base.py @ 3834:3260401fdb98

cli: helper method to retrieve profile's jid: rel 369
author Goffi <goffi@goffi.org>
date Sun, 10 Jul 2022 16:15:09 +0200
parents ea204216a505
children 915fb230cb28
comparison
equal deleted inserted replaced
3833:381340b9a9ee 3834:3260401fdb98
695 async def main(self, args, namespace): 695 async def main(self, args, namespace):
696 try: 696 try:
697 await self.bridge.bridgeConnect() 697 await self.bridge.bridgeConnect()
698 except Exception as e: 698 except Exception as e:
699 if isinstance(e, exceptions.BridgeExceptionNoService): 699 if isinstance(e, exceptions.BridgeExceptionNoService):
700 print(_("Can't connect to SàT backend, are you sure it's launched ?")) 700 print(
701 _("Can't connect to Libervia backend, are you sure that it's "
702 "launched ?")
703 )
701 self.quit(C.EXIT_BACKEND_NOT_FOUND, raise_exc=False) 704 self.quit(C.EXIT_BACKEND_NOT_FOUND, raise_exc=False)
702 elif isinstance(e, exceptions.BridgeInitError): 705 elif isinstance(e, exceptions.BridgeInitError):
703 print(_("Can't init bridge")) 706 print(_("Can't init bridge"))
704 self.quit(C.EXIT_BRIDGE_ERROR, raise_exc=False) 707 self.quit(C.EXIT_BRIDGE_ERROR, raise_exc=False)
705 else: 708 else:
965 #if the resource is not given, we try to add the main resource 968 #if the resource is not given, we try to add the main resource
966 main_resource = await self.bridge.getMainResource(param_jid, self.profile) 969 main_resource = await self.bridge.getMainResource(param_jid, self.profile)
967 if main_resource: 970 if main_resource:
968 return f"{_jid.bare}/{main_resource}" 971 return f"{_jid.bare}/{main_resource}"
969 return param_jid 972 return param_jid
973
974 async def get_profile_jid(self):
975 """Retrieve current profile bare JID if possible"""
976 full_jid = await self.bridge.asyncGetParamA(
977 "JabberID", "Connection", profile_key=self.profile
978 )
979 return full_jid.rsplit("/", 1)[0]
970 980
971 981
972 class CommandBase(object): 982 class CommandBase(object):
973 983
974 def __init__(self, host, name, use_profile=True, use_output=False, extra_outputs=None, 984 def __init__(self, host, name, use_profile=True, use_output=False, extra_outputs=None,