Skip to content

Commit

Permalink
🔥 suppress pip install output. #378 (#379)
Browse files Browse the repository at this point in the history
* 🔥 suppress pip install output. #378

* 💄 update coding style

* prepare for release
  • Loading branch information
chfw authored May 13, 2020
1 parent 1652919 commit 10ba852
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 26 deletions.
7 changes: 7 additions & 0 deletions .moban.cd/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
name: moban
organisation: moremoban
releases:
- changes:
- action: Fixed
details:
- "`#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
details:
Expand Down
6 changes: 3 additions & 3 deletions .moban.cd/moban.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ organisation: moremoban
author: C. W.
contact: wangc_2011@hotmail.com
license: MIT
version: 0.7.3
current_version: 0.7.3
release: 0.7.3
version: 0.7.4
current_version: 0.7.4
release: 0.7.4
branch: master
master: index
command_line_interface: "moban"
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Change log
================================================================================

0.7.4 - 13.5.2020
--------------------------------------------------------------------------------

**Fixed**

#. `#378 <https://github.com/moremoban/moban/issues/378>`_: suppress stdout
message from deprecated pip install. but please do not use and migrate
deprecated`requires` syntax.

0.7.3 - 2.5.2020
--------------------------------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
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'
release = '0.7.4'

# -- General configuration ---------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion moban/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "0.7.3"
__version__ = "0.7.4"
__author__ = "C. W."
2 changes: 1 addition & 1 deletion moban/core/moban_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 3 additions & 1 deletion moban/deprecated/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ 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,
)


Expand Down
24 changes: 14 additions & 10 deletions moban/externals/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
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),
Expand All @@ -27,36 +27,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):
Expand All @@ -69,12 +69,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):
Expand All @@ -90,3 +90,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)
1 change: 1 addition & 0 deletions moban/plugins/jinja2/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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",
Expand Down Expand Up @@ -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 = (
Expand Down
6 changes: 3 additions & 3 deletions tests/integration_tests/test_command_line_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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,
)


Expand Down
4 changes: 3 additions & 1 deletion tests/test_file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,5 +272,7 @@ 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,
)

0 comments on commit 10ba852

Please sign in to comment.