changeset 3765:ea204216a505

CLI: don't fail when calling `getContacts` with a component profile
author Goffi <goffi@goffi.org>
date Fri, 13 May 2022 19:15:30 +0200
parents 125c7043b277
children e5166f60743c
files sat_frontends/jp/base.py
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/sat_frontends/jp/base.py	Fri May 13 19:12:33 2022 +0200
+++ b/sat_frontends/jp/base.py	Fri May 13 19:15:30 2022 +0200
@@ -801,7 +801,17 @@
         names2jid = {}
         nodes2jid = {}
 
-        for contact in await self.bridge.getContacts(self.profile):
+        try:
+            contacts = await self.bridge.getContacts(self.profile)
+        except BridgeException as e:
+            if e.classname == "AttributeError":
+                # we may get an AttributeError if we use a component profile
+                # as components don't have roster
+                contacts = []
+            else:
+                raise e
+
+        for contact in contacts:
             jid_s, attr, groups = contact
             _jid = JID(jid_s)
             try: