diff --git a/.moban.cd/changelog.yml b/.moban.cd/changelog.yml index f004d3b0..9713f0bf 100644 --- a/.moban.cd/changelog.yml +++ b/.moban.cd/changelog.yml @@ -1,6 +1,13 @@ name: moban organisation: moremoban releases: + - changes: + - action: Added + details: + - "`#378`: suppress stdout message from deprecated pip install. + but please do not use and migrate deprecated`requires` syntax." + date: tbd + version: 0.7.4 - changes: - action: Added details: diff --git a/.moban.cd/moban.yml b/.moban.cd/moban.yml index f68d4fcf..cc05174c 100644 --- a/.moban.cd/moban.yml +++ b/.moban.cd/moban.yml @@ -4,8 +4,8 @@ organisation: moremoban author: C. W. contact: wangc_2011@hotmail.com license: MIT -version: 0.7.3 -current_version: 0.7.3 +version: 0.7.4 +current_version: 0.7.4 release: 0.7.3 branch: master master: index diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 64bedd15..bae7e81a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,15 @@ Change log ================================================================================ +0.7.4 - tbd +-------------------------------------------------------------------------------- + +**Added** + +#. `#378 `_: suppress stdout + message from deprecated pip install. but please do not use and migrate + deprecated`requires` syntax. + 0.7.3 - 2.5.2020 -------------------------------------------------------------------------------- diff --git a/docs/conf.py b/docs/conf.py index 1d95d9d6..61649cc4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -25,7 +25,7 @@ copyright = '2017-2020 Onni Software Ltd.' author = 'C. W.' # The short X.Y version -version = '0.7.3' +version = '0.7.4' # The full version, including alpha/beta/rc tags release = '0.7.3' diff --git a/moban/_version.py b/moban/_version.py index b24d8ae7..9d09cc8a 100644 --- a/moban/_version.py +++ b/moban/_version.py @@ -1,2 +1,2 @@ -__version__ = "0.7.3" +__version__ = "0.7.4" __author__ = "C. W." diff --git a/moban/core/moban_factory.py b/moban/core/moban_factory.py index 5b4ad8c5..e80013f5 100644 --- a/moban/core/moban_factory.py +++ b/moban/core/moban_factory.py @@ -49,8 +49,8 @@ def get_engine(self, template_type, template_dirs, context_dirs): template_dirs = utils.verify_the_existence_of_directories( template_dirs ) - if template_type in self.options_registry: + custom_engine_spec = self.options_registry[template_type] engine_cls = self.load_me_now( custom_engine_spec[constants.TEMPLATE_TYPES_BASE_TYPE] diff --git a/moban/deprecated/__init__.py b/moban/deprecated/__init__.py index 2751b422..576f1ec9 100644 --- a/moban/deprecated/__init__.py +++ b/moban/deprecated/__init__.py @@ -65,7 +65,8 @@ def pip_install(packages): import subprocess subprocess.check_call( - [sys.executable, "-m", "pip", "install", " ".join(packages)] + [sys.executable, "-m", "pip", "install", " ".join(packages)], + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL ) diff --git a/moban/externals/reporter.py b/moban/externals/reporter.py index 101f61c5..6054b7ff 100644 --- a/moban/externals/reporter.py +++ b/moban/externals/reporter.py @@ -14,10 +14,11 @@ type" + def report_templating( action_in_present_continuous_tense, source_file, destination_file ): - print( + do_print( MESSAGE_TEMPLATING.format( action_in_present_continuous_tense, crayons.yellow(source_file), @@ -27,36 +28,36 @@ def report_templating( def report_no_action(): - print(crayons.yellow(MESSAGE_NO_TEMPLATING, bold=True)) + do_print(crayons.yellow(MESSAGE_NO_TEMPLATING, bold=True)) def report_full_run(action_in_past_tense, file_count): figure = crayons.green(str(file_count), bold=True) message = MESSAGE_TEMPLATED_ALL.format(action_in_past_tense, figure) - print(_format_single(message, file_count)) + do_print(_format_single(message, file_count)) def report_partial_run(action_in_past_tense, file_count, total): figure = crayons.green(str(file_count), bold=True) total_figure = crayons.yellow(str(total), bold=True) message = MESSAGE_REPORT.format(action_in_past_tense, figure, total_figure) - print(_format_single(message, total)) + do_print(_format_single(message, total)) def report_error_message(message): - print(crayons.white("Error: ", bold=True) + crayons.red(message)) + do_print(crayons.white("Error: ", bold=True) + crayons.red(message)) def report_warning_message(message): - print(crayons.white("Warning: ", bold=True) + crayons.yellow(message)) + do_print(crayons.white("Warning: ", bold=True) + crayons.yellow(message)) def report_info_message(message): - print(crayons.white("Info: ") + crayons.green(message)) + do_print(crayons.white("Info: ") + crayons.green(message)) def report_up_to_date(): - print(crayons.green(MESSAGE_UP_TO_DATE, bold=True)) + do_print(crayons.green(MESSAGE_UP_TO_DATE, bold=True)) def convert_to_shell_exit_code(number_of_templated_files): @@ -69,12 +70,12 @@ def convert_to_shell_exit_code(number_of_templated_files): def report_git_pull(repo): colored_repo = crayons.green(repo, bold=True) - print(MESSAGE_PULLING_REPO.format(colored_repo)) + do_print(MESSAGE_PULLING_REPO.format(colored_repo)) def report_git_clone(repo): colored_repo = crayons.green(repo, bold=True) - print(MESSAGE_CLONING_REPO.format(colored_repo)) + do_print(MESSAGE_CLONING_REPO.format(colored_repo)) def report_template_not_in_moban_file(template): @@ -90,3 +91,7 @@ def _format_single(message, count): def report_file_extension_not_needed(): report_info_message(MESSAGE_FILE_EXTENSION_NOT_NEEDED) + + +def do_print(message): + print(message) diff --git a/moban/plugins/jinja2/engine.py b/moban/plugins/jinja2/engine.py index 507d33e3..aaacc73d 100644 --- a/moban/plugins/jinja2/engine.py +++ b/moban/plugins/jinja2/engine.py @@ -86,6 +86,7 @@ def __init__(self, template_fs, options=None): ], # get a copy of this global variable ) self.template_loader = template_loader + if options: if "extensions" in options: extensions = options.pop("extensions") diff --git a/setup.py b/setup.py index 2b5766e8..f3ba9203 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,7 @@ NAME = "moban" AUTHOR = "C. W." -VERSION = "0.7.3" +VERSION = "0.7.4" EMAIL = "wangc_2011@hotmail.com" LICENSE = "MIT" ENTRY_POINTS = { diff --git a/tests/integration_tests/test_command_line_options.py b/tests/integration_tests/test_command_line_options.py index 25e82f27..7244202d 100644 --- a/tests/integration_tests/test_command_line_options.py +++ b/tests/integration_tests/test_command_line_options.py @@ -449,9 +449,9 @@ def test_version_option(): @patch("logging.basicConfig") -def test_debug_option(fake_config): +def test_warning_verbose(fake_config): fake_config.side_effect = [IOError("stop test")] - test_args = ["moban", "-vv"] + test_args = ["moban", "-vvv"] with patch.object(sys, "argv", test_args): from moban.main import main @@ -460,7 +460,7 @@ def test_debug_option(fake_config): except IOError: fake_config.assert_called_with( format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", - level=20, + level=10, ) diff --git a/tests/test_file_system.py b/tests/test_file_system.py index 362fb281..dab1437f 100644 --- a/tests/test_file_system.py +++ b/tests/test_file_system.py @@ -272,5 +272,6 @@ def test_pip_install(fake_check_all): pip_install(["package1", "package2"]) fake_check_all.assert_called_with( - [sys.executable, "-m", "pip", "install", "package1 package2"] + [sys.executable, "-m", "pip", "install", "package1 package2"], + stderr=-3, stdout=-3 )