From 6ac1dc88d27c74c12707bb1d087b0f7c15a245d2 Mon Sep 17 00:00:00 2001 From: William Luke Date: Mon, 2 May 2022 08:45:32 +0300 Subject: [PATCH] chore: small cleanup --- clicada/cli/arg.py | 4 ++-- clicada/cli/user.py | 22 +++++++++++++--------- setup.cfg | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/clicada/cli/arg.py b/clicada/cli/arg.py index 68db07a..22054ad 100644 --- a/clicada/cli/arg.py +++ b/clicada/cli/arg.py @@ -198,10 +198,10 @@ class CmdCtrl: def notify(self, v): if logg.root.level <= logging.INFO: - print(v) + print("\033[96m" + v + "\033[0m") def ouch(self, v): - print(v) + print("\033[91m" + v + "\033[0m") def write(self, v): print(v) diff --git a/clicada/cli/user.py b/clicada/cli/user.py index d109a4c..c4f5606 100644 --- a/clicada/cli/user.py +++ b/clicada/cli/user.py @@ -109,26 +109,30 @@ def execute(ctrl): encrypter=ctrl.encrypter, ) - ctrl.notify("resolving metadata for address {}".format(user_address_normal)) r = None + ctrl.write( + f""" +Phone: {ctrl.get("_IDENTIFIER")} +Network address: {add_0x(user_address)} +Chain: {ctrl.chain().common_name()}""" + ) + ctrl.notify("resolving metadata for address {}".format(user_address_normal)) try: r = user_address_store.by_address( user_address_normal, update=ctrl.get("_FORCE") ) - except MetadataNotFoundError as e: - ctrl.ouch("could not resolve metadata for user: {}".format(e)) - - ctrl.write( - f"""Phone: {ctrl.get("_IDENTIFIER")} -Network address: {add_0x(user_address)} -Chain: {ctrl.chain().common_name()} + if r: + ctrl.write( + f""" Name: { str(r)} Registered: {datetime.datetime.fromtimestamp(r.date_registered).ctime()} Gender: {r.gender} Location: {r.location["area_name"]} Products: {",".join(r.products)} Tags: {",".join(r.tags)}""" - ) + ) + except MetadataNotFoundError as e: + ctrl.ouch(f"MetadataNotFoundError: Could not resolve metadata for user {e}\n") tx_lines = [] seen_tokens = {} diff --git a/setup.cfg b/setup.cfg index c509dea..18c64bb 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = clicada -version = 0.1.2 +version = 0.1.3 description = CLI CRM tool for the cic-stack custodial wallet system author = Louis Holbrook author_email = dev@holbrook.no