diff --git a/silkaj/commands.py b/silkaj/commands.py index d65a124d6481657809f0514968559881f00a9810..adad2ec56e760fc0c3a2338315eb786c691d0927 100644 --- a/silkaj/commands.py +++ b/silkaj/commands.py @@ -17,6 +17,7 @@ from collections import OrderedDict from operator import itemgetter from os import system from typing import Dict, List, Tuple +from urllib.error import HTTPError import jsonschema from click import IntRange, argument, command, option @@ -151,14 +152,17 @@ def list_blocks(number: int, detailed: bool) -> None: issuers.append(issuer) for pubkey in issuers_dict.keys(): issuer = issuers_dict[pubkey] - idty = identity_of(issuer["pubkey"]) + try: + idty = identity_of(issuer["pubkey"]) + except HTTPError: + idty = None for issuer2 in issuers: if ( issuer2.get("pubkey") is not None and issuer.get("pubkey") is not None and issuer2["pubkey"] == issuer["pubkey"] ): - issuer2["uid"] = idty["uid"] + issuer2["uid"] = idty["uid"] if idty else None issuer2.pop("pubkey") header = ( f"Last {number} blocks from n°{current_nbr - number + 1} to n°{current_nbr}" diff --git a/silkaj/wot_tools.py b/silkaj/wot_tools.py index f92c81b58133cd1a3a3328ab68fe3c972e106587..dc6f286a5df6917c0bc1cdfea348690970f6824b 100644 --- a/silkaj/wot_tools.py +++ b/silkaj/wot_tools.py @@ -14,6 +14,7 @@ # along with Silkaj. If not, see <https://www.gnu.org/licenses/>. from typing import Dict, List, Optional +from urllib.error import HTTPError from duniterpy.api.bma import wot @@ -27,10 +28,7 @@ def identity_of(pubkey_uid: str) -> Dict: Able to know if an identity is member or not """ client = client_instance() - try: - return client(wot.identity_of, pubkey_uid) - except ValueError: - pass + return client(wot.identity_of, pubkey_uid) def is_member(pubkey_uid: str) -> Optional[Dict]: @@ -40,7 +38,7 @@ def is_member(pubkey_uid: str) -> Optional[Dict]: """ try: return identity_of(pubkey_uid) - except Exception: + except HTTPError: return None @@ -67,6 +65,6 @@ def identities_from_pubkeys(pubkeys: List[str], uids: bool) -> List: for pubkey in uniq_pubkeys: try: identities.append(identity_of(pubkey)) - except Exception: + except HTTPError: pass return identities