From fa992fe5de4a80e30522cf76d5ca415c30ba2233 Mon Sep 17 00:00:00 2001 From: chfw Date: Wed, 13 May 2020 23:30:08 +0100 Subject: [PATCH 1/3] :fire: suppress pip install output. #378 --- .moban.cd/changelog.yml | 7 ++++++ .moban.cd/moban.yml | 4 +-- CHANGELOG.rst | 9 +++++++ docs/conf.py | 2 +- moban/_version.py | 2 +- moban/core/moban_factory.py | 2 +- moban/deprecated/__init__.py | 3 ++- moban/externals/reporter.py | 25 +++++++++++-------- moban/plugins/jinja2/engine.py | 1 + setup.py | 2 +- .../test_command_line_options.py | 6 ++--- tests/test_file_system.py | 3 ++- 12 files changed, 45 insertions(+), 21 deletions(-) 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 ) From e1879f39ecca7397ded9bbb34ea2693b8441640c Mon Sep 17 00:00:00 2001 From: chfw Date: Wed, 13 May 2020 23:38:01 +0100 Subject: [PATCH 2/3] :lipstick: update coding style --- moban/deprecated/__init__.py | 3 ++- moban/externals/reporter.py | 1 - tests/test_file_system.py | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/moban/deprecated/__init__.py b/moban/deprecated/__init__.py index 576f1ec9..9fe73122 100644 --- a/moban/deprecated/__init__.py +++ b/moban/deprecated/__init__.py @@ -66,7 +66,8 @@ def pip_install(packages): subprocess.check_call( [sys.executable, "-m", "pip", "install", " ".join(packages)], - stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, ) diff --git a/moban/externals/reporter.py b/moban/externals/reporter.py index 6054b7ff..fe06345d 100644 --- a/moban/externals/reporter.py +++ b/moban/externals/reporter.py @@ -14,7 +14,6 @@ type" - def report_templating( action_in_present_continuous_tense, source_file, destination_file ): diff --git a/tests/test_file_system.py b/tests/test_file_system.py index dab1437f..994d8f66 100644 --- a/tests/test_file_system.py +++ b/tests/test_file_system.py @@ -273,5 +273,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"], - stderr=-3, stdout=-3 + stderr=-3, + stdout=-3, ) From 8d1a2e476f3753449448b07b59fb3f54e2fb4bfb Mon Sep 17 00:00:00 2001 From: chfw Date: Wed, 13 May 2020 23:41:57 +0100 Subject: [PATCH 3/3] prepare for release --- .moban.cd/changelog.yml | 8 ++++---- .moban.cd/moban.yml | 2 +- CHANGELOG.rst | 4 ++-- docs/conf.py | 2 +- setup.py | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.moban.cd/changelog.yml b/.moban.cd/changelog.yml index 9713f0bf..8dfd9a32 100644 --- a/.moban.cd/changelog.yml +++ b/.moban.cd/changelog.yml @@ -2,11 +2,11 @@ name: moban organisation: moremoban releases: - changes: - - action: Added + - action: Fixed details: - - "`#378`: suppress stdout message from deprecated pip install. - but please do not use and migrate deprecated`requires` syntax." - date: tbd + - "`#378`: suppress stdout message from deprecated pip install. + but please do not use and migrate deprecated`requires` syntax." + date: 13.5.2020 version: 0.7.4 - changes: - action: Added diff --git a/.moban.cd/moban.yml b/.moban.cd/moban.yml index cc05174c..254fbcbc 100644 --- a/.moban.cd/moban.yml +++ b/.moban.cd/moban.yml @@ -6,7 +6,7 @@ contact: wangc_2011@hotmail.com license: MIT version: 0.7.4 current_version: 0.7.4 -release: 0.7.3 +release: 0.7.4 branch: master master: index command_line_interface: "moban" diff --git a/CHANGELOG.rst b/CHANGELOG.rst index bae7e81a..429fdccf 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,10 +1,10 @@ Change log ================================================================================ -0.7.4 - tbd +0.7.4 - 13.5.2020 -------------------------------------------------------------------------------- -**Added** +**Fixed** #. `#378 `_: suppress stdout message from deprecated pip install. but please do not use and migrate diff --git a/docs/conf.py b/docs/conf.py index 61649cc4..2df2ec9f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -27,7 +27,7 @@ # The short X.Y version version = '0.7.4' # The full version, including alpha/beta/rc tags -release = '0.7.3' +release = '0.7.4' # -- General configuration --------------------------------------------------- diff --git a/setup.py b/setup.py index f3ba9203..78fa3139 100644 --- a/setup.py +++ b/setup.py @@ -53,7 +53,7 @@ "General purpose static text generator" ) URL = "https://github.com/moremoban/moban" -DOWNLOAD_URL = "%s/archive/0.7.3.tar.gz" % URL +DOWNLOAD_URL = "%s/archive/0.7.4.tar.gz" % URL FILES = ["README.rst", "CONTRIBUTORS.rst", "CHANGELOG.rst"] KEYWORDS = [ "python", @@ -96,8 +96,8 @@ } # You do not need to read beyond this line PUBLISH_COMMAND = "{0} setup.py sdist bdist_wheel upload -r pypi".format(sys.executable) -GS_COMMAND = ("gs moban v0.7.3 " + - "Find 0.7.3 in changelog for more details") +GS_COMMAND = ("gs moban v0.7.4 " + + "Find 0.7.4 in changelog for more details") NO_GS_MESSAGE = ("Automatic github release is disabled. " + "Please install gease to enable it.") UPLOAD_FAILED_MSG = (