|
|
|
@ -2,7 +2,7 @@ |
|
|
|
|
|
|
|
|
|
from typing import MutableMapping, Any |
|
|
|
|
|
|
|
|
|
from sys import argv, executable |
|
|
|
|
from sys import argv, executable, stdout |
|
|
|
|
from os import environ, getcwd, sep as psep |
|
|
|
|
from os.path import dirname, abspath, join as joinpath, \ |
|
|
|
|
expanduser, splitdrive, isfile |
|
|
|
@ -28,6 +28,9 @@ import zasd.config as _config |
|
|
|
|
_CONFIG_BASENAME = 'zasd.conf.py' |
|
|
|
|
_CONFIG_FILENAMES = [_CONFIG_BASENAME, '.' + _CONFIG_BASENAME] |
|
|
|
|
|
|
|
|
|
_WARNING_WAIT = 3 |
|
|
|
|
#_WARNING_WAIT = 10 |
|
|
|
|
|
|
|
|
|
# Default configuration |
|
|
|
|
_DEFAULT_CONFIG = dict( |
|
|
|
|
zfs_path = '/usr/local/bin/zfs', |
|
|
|
@ -142,20 +145,23 @@ async def load_config(): |
|
|
|
|
|
|
|
|
|
log.debug('Loaded configuration') |
|
|
|
|
|
|
|
|
|
#if _config.get('log_level') <= logging.DEBUG: |
|
|
|
|
log.debug('') |
|
|
|
|
for line in pprint.pformat(_config.reference()).split('\n'): |
|
|
|
|
logging.debug(_config.get('tab_size') * ' ' + line) |
|
|
|
|
log.debug('') |
|
|
|
|
if _config.get('log_level') <= logging.DEBUG: |
|
|
|
|
log.debug('') |
|
|
|
|
for line in pprint.pformat(_config).split('\n'): |
|
|
|
|
logging.debug(_config.get('tab_size') * ' ' + line) |
|
|
|
|
log.debug('') |
|
|
|
|
|
|
|
|
|
async def _warn_default(): |
|
|
|
|
log.warning('') |
|
|
|
|
log.warning('Waiting 10 seconds before loading default configuration...') |
|
|
|
|
log.warning( |
|
|
|
|
'Waiting %s seconds before loading default configuration...', |
|
|
|
|
_WARNING_WAIT) |
|
|
|
|
log.warning('') |
|
|
|
|
await asyncio.sleep(10) |
|
|
|
|
await asyncio.sleep(_WARNING_WAIT) |
|
|
|
|
stdout.write('\r') |
|
|
|
|
log.warning('Loading default configuration') |
|
|
|
|
log.warning('') |
|
|
|
|
return deepcopy(_DEFAULT_CONFIG) |
|
|
|
|
_config.change(deepcopy(_DEFAULT_CONFIG)) |
|
|
|
|
|
|
|
|
|
# pylint: disable=dangerous-default-value |
|
|
|
|
def _merge_configs(base, diff, path=[]): |