two small fixes: bugfix with older python and error ran into with a user program

This commit is contained in:
Mathew Guest 2020-07-19 00:34:10 -06:00
parent 076e609b80
commit c74f09a3c4
2 changed files with 22 additions and 5 deletions

@ -80,11 +80,25 @@ class CommandTree:
Creates a root-level submenu with no entries. SubMenu node is
returned which can have submenus and commands attached to it.
"""
# NOTE(MG) Fix below strategizes whether to pass in 'required'
# paremter to ArgumentParser.add_subparsers()
# which was added in in Python3.7.
func_args = {
'dest': param_name,
'metavar': param_name,
'required': is_required
}
if (
sys.version_info.major == 3
and sys.version_info.minor <= 6
):
if is_required:
_bootstrap_logger.warn('Unable to enforce required submenu: Requires >= Python 3.7')
del func_args[required]
# Creates an argument as a slot in the underlying argparse.
subparsers = self.root_parser.add_subparsers(
dest = param_name,
metavar = param_name,
required = is_required
**func_args
)
submenu = SubMenu(self, subparsers, param_name)

@ -108,8 +108,11 @@ class LoggingLayer:
# Replace 'root' logger with '', logging module convention for root handler
# Note: '' is disallowed in ConfigObj (hence the reason for this replacement)
config_dict['loggers'][''] = config_dict['loggers']['root']
del config_dict['loggers']['root']
try:
config_dict['loggers'][''] = config_dict['loggers']['root']
del config_dict['loggers']['root']
except Exception as ex:
_bootstrap.logger.warn('internal failure patching root logger')
# Evaluate the full filepath of the file handler