Ensure all changes for home config dir override are applied to version

This commit is contained in:
nolash 2021-12-17 07:50:01 +00:00
parent 3739038340
commit b552c933d7
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
5 changed files with 31 additions and 10 deletions

View File

@ -1,3 +1,5 @@
- 0.0.1
- 0.0.2
* Use ~/.config for default config override
- 0.0.1-unreleased
* Add tx listing
* Add phone to user resolver

View File

@ -18,6 +18,8 @@ from clicada.cli.http import (
PGPClientSession,
)
logg = logging.getLogger()
script_dir = os.path.dirname(os.path.realpath(__file__))
data_dir = os.path.join(script_dir, '..', 'data')
base_config_dir = os.path.join(data_dir, 'config')
@ -40,7 +42,7 @@ class CmdCtrl:
self.logging(logger)
self.module()
self.config()
self.auth()
@ -69,6 +71,7 @@ class CmdCtrl:
cmd_tag.process_args(sub_tag)
self.cmd_args = self.argparser.parse_args(argv)
print(self.cmd_args)
def module(self):
@ -96,11 +99,19 @@ class CmdCtrl:
def config(self):
override_dir = self.cmd_args.config
if override_dir == None:
p = os.environ.get('HOME')
if p != None:
p = os.path.join(p, '.config', 'cic', 'clicada')
try:
os.stat(p)
override_dir = p
logg.info('applying user config override from standard location: {}'.format(p))
except FileNotFoundError:
pass
extra_args = self.cmd_mod.extra_args()
if self.cmd_args.config:
self.config = chainlib.eth.cli.Config.from_args(self.cmd_args, base_config_dir=base_config_dir, extra_args=extra_args, default_config_dir=self.cmd_args.config)
else:
self.config = chainlib.eth.cli.Config.from_args(self.cmd_args, base_config_dir=base_config_dir, extra_args=extra_args)
self.config = chainlib.eth.cli.Config.from_args(self.cmd_args, base_config_dir=base_config_dir, extra_args=extra_args, default_config_dir=override_dir)
self.config.add(False, '_SEQ')
@ -113,7 +124,9 @@ class CmdCtrl:
typ = self.get('AUTH_TYPE')
if typ != 'gnupg':
raise NotImplementedError('Valid aut implementations are: gnupg')
default_auth_db_path = os.path.join(os.environ['HOME'], '.local/share/cic/clicada')
default_auth_db_path = None
if os.environ.get('HOME') != None:
default_auth_db_path = os.path.join(os.environ['HOME'], '.local/share/cic/clicada')
auth_db_path = self.get('AUTH_DB_PATH', default_auth_db_path)
self.__auth = PGPAuthCrypt(auth_db_path, self.get('AUTH_KEY'), self.get('AUTH_KEYRING_PATH'))
self.__auth.get_secret(self.get('AUTH_PASSPHRASE'))

View File

@ -8,6 +8,7 @@ from cic_eth_registry import CICRegistry
from cic_eth_registry.lookup.tokenindex import TokenIndexLookup
from cic_types.models.person import Person
from chainlib.eth.address import to_checksum_address
from chainlib.encode import TxHexNormalizer
from hexathon import add_0x
# local imports
@ -21,6 +22,8 @@ from clicada.tx import ResolvedTokenTx
logg = logging.getLogger(__name__)
tx_normalizer = TxHexNormalizer()
def process_args(argparser):
argparser.add_argument('-m', '--method', type=str, help='lookup method')
@ -73,7 +76,10 @@ def execute(ctrl):
user_address_file_label = 'address'
user_address_store = FileUserStore(ctrl.opener('meta'), ctrl.chain(), user_address_file_label, store_path, int(ctrl.get('FILESTORE_TTL')))
r = user_address_store.by_address(user_address, update=ctrl.get('_FORCE'))
user_address_normal = tx_normalizer.wallet_address(user_address)
r = user_address_store.by_address(user_address_normal, update=ctrl.get('_FORCE'))
print('r {}'.format(r))
print("""Phone: {}
Network address: {}

View File

@ -5,7 +5,7 @@ import logging
# local imports
from clicada.cli import CmdCtrl
logging.basicConfig(level=logging.WARNING)
logging.basicConfig(level=logging.DEBUG)
logg = logging.getLogger()

View File

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