From 1d622467e46a3cdf70637903e40d11930443442b Mon Sep 17 00:00:00 2001 From: skullY Date: Sun, 8 Sep 2019 21:21:04 -0700 Subject: [PATCH] Fix logging so certain modules don't output unwanted debug messages --- milc.py | 11 +++++++---- qmk_cli/script_qmk.py | 3 +-- setup.py | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/milc.py b/milc.py index ae04bb5..d0749ea 100644 --- a/milc.py +++ b/milc.py @@ -38,6 +38,9 @@ import argcomplete import colorama from appdirs import user_config_dir +# Disable logging until we can configure it how the user wants +logging.basicConfig(filename='/dev/null') + # Log Level Representations EMOJI_LOGLEVELS = { 'CRITICAL': '{bg_red}{fg_white}¬_¬{style_reset_all}', @@ -424,7 +427,7 @@ class MILC(object): if 'arg_only' in kwargs and kwargs['arg_only']: arg_name = self.get_argument_name(*args, **kwargs) self.arg_only.append(arg_name) - del(kwargs['arg_only']) + del kwargs['arg_only'] if handler is self._entrypoint: self.add_argument(*args, **kwargs) @@ -513,7 +516,6 @@ class MILC(object): if option not in self.config[section]: self.config[section][option] = getattr(self.args, argument) - self.release_lock() def save_config(self): @@ -617,6 +619,7 @@ class MILC(object): def subcommand(self, description, **kwargs): """Decorator to register a subcommand. """ + def subcommand_function(handler): return self.add_subcommand(handler, description, **kwargs) @@ -626,8 +629,8 @@ class MILC(object): """Called by __enter__() to setup the logging configuration. """ if len(logging.root.handlers) != 0: - # This is not a design decision. This is what I'm doing for now until I can examine and think about this situation in more detail. - raise RuntimeError('MILC should be the only system installing root log handlers!') + # MILC is the only thing that should have root log handlers + logging.root.handlers = [] self.acquire_lock() diff --git a/qmk_cli/script_qmk.py b/qmk_cli/script_qmk.py index 7e96aea..508be6b 100644 --- a/qmk_cli/script_qmk.py +++ b/qmk_cli/script_qmk.py @@ -16,7 +16,6 @@ from pkgutil import walk_packages import milc - SUBCOMMAND_BLACKLIST = ['qmk.cli.subcommands'] milc.EMOJI_LOGLEVELS['INFO'] = '{fg_blue}Ψ{style_reset_all}' @@ -89,7 +88,7 @@ def main(): for count, arg in enumerate(sys.argv[1:]): if arg and arg[0] != '-': - sys.argv[count+1] = subcommand = arg.replace('-', '_') + sys.argv[count + 1] = subcommand = arg.replace('-', '_') subcommand = subcommand.replace('_', '.') break diff --git a/setup.py b/setup.py index a0fdc19..58436c7 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ if __name__ == "__main__": name=metadata['dist-name'], description='A program to help users work with QMK Firmware.', entry_points={ - 'console_scripts': ['%s = %s' % l for l in setup_cfg['entry_points'].items()] + 'console_scripts': ['%s = %s' % l for l in setup_cfg['entry_points'].items()], }, license='MIT License', url=metadata['home-page'],