chore: small cleanup

This commit is contained in:
William Luke 2022-05-02 08:45:32 +03:00
parent a3a3f55234
commit 6ac1dc88d2
3 changed files with 16 additions and 12 deletions

View File

@ -198,10 +198,10 @@ class CmdCtrl:
def notify(self, v): def notify(self, v):
if logg.root.level <= logging.INFO: if logg.root.level <= logging.INFO:
print(v) print("\033[96m" + v + "\033[0m")
def ouch(self, v): def ouch(self, v):
print(v) print("\033[91m" + v + "\033[0m")
def write(self, v): def write(self, v):
print(v) print(v)

View File

@ -109,26 +109,30 @@ def execute(ctrl):
encrypter=ctrl.encrypter, encrypter=ctrl.encrypter,
) )
ctrl.notify("resolving metadata for address {}".format(user_address_normal))
r = None 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: try:
r = user_address_store.by_address( r = user_address_store.by_address(
user_address_normal, update=ctrl.get("_FORCE") user_address_normal, update=ctrl.get("_FORCE")
) )
except MetadataNotFoundError as e: if r:
ctrl.ouch("could not resolve metadata for user: {}".format(e)) ctrl.write(
f"""
ctrl.write(
f"""Phone: {ctrl.get("_IDENTIFIER")}
Network address: {add_0x(user_address)}
Chain: {ctrl.chain().common_name()}
Name: { str(r)} Name: { str(r)}
Registered: {datetime.datetime.fromtimestamp(r.date_registered).ctime()} Registered: {datetime.datetime.fromtimestamp(r.date_registered).ctime()}
Gender: {r.gender} Gender: {r.gender}
Location: {r.location["area_name"]} Location: {r.location["area_name"]}
Products: {",".join(r.products)} Products: {",".join(r.products)}
Tags: {",".join(r.tags)}""" Tags: {",".join(r.tags)}"""
) )
except MetadataNotFoundError as e:
ctrl.ouch(f"MetadataNotFoundError: Could not resolve metadata for user {e}\n")
tx_lines = [] tx_lines = []
seen_tokens = {} seen_tokens = {}

View File

@ -1,6 +1,6 @@
[metadata] [metadata]
name = clicada name = clicada
version = 0.1.2 version = 0.1.3
description = CLI CRM tool for the cic-stack custodial wallet system description = CLI CRM tool for the cic-stack custodial wallet system
author = Louis Holbrook author = Louis Holbrook
author_email = dev@holbrook.no author_email = dev@holbrook.no