Merge pull request #5581 from pypa/fix-verbose-logging

Fix verbose logging
This commit is contained in:
Oz Tiram
2023-01-30 21:37:15 +01:00
committed by GitHub
5 changed files with 20 additions and 25 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ repos:
exclude: tests/data
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
files: \.py$
+1
View File
@@ -0,0 +1 @@
Fix overwriting of output in verbose mode
+9 -17
View File
@@ -259,7 +259,9 @@ def ensure_pipfile(project, validate=True, skip_requirements=False, system=False
except Exception:
err.print(environments.PIPENV_SPINNER_FAIL_TEXT.format("Failed..."))
else:
st.update(environments.PIPENV_SPINNER_OK_TEXT.format("Success!"))
st.console.print(
environments.PIPENV_SPINNER_OK_TEXT.format("Success!")
)
# Warn the user of side-effects.
click.echo(
"{0}: Your {1} now contains pinned versions, if your {2} did. \n"
@@ -2305,7 +2307,7 @@ def do_install(
os.environ["PIP_USER"] = "0"
if "PYTHONHOME" in os.environ:
del os.environ["PYTHONHOME"]
st.update(f"Resolving {pkg_line}...")
st.console.print(f"Resolving {pkg_line}...")
try:
pkg_requirement = Requirement.from_line(pkg_line)
except ValueError as e:
@@ -2316,11 +2318,11 @@ def do_install(
)
)
sys.exit(1)
st.update("Installing...")
st.console.print("Installing...")
try:
st.update(f"Installing {pkg_requirement.name}...")
if project.s.is_verbose():
st.update(
st.console.print(
f"Installing package: {pkg_requirement.as_line(include_hashes=False)}"
)
c = pip_install(
@@ -2393,18 +2395,8 @@ def do_install(
pipfile_sections = "[dev-packages]"
else:
pipfile_sections = "[packages]"
st.update(
"{} {} {} {}{}".format(
click.style("Adding", bold=True),
click.style(f"{pkg_requirement.name}", fg="green", bold=True),
click.style("to Pipfile's", bold=True),
click.style(
pipfile_sections,
fg="yellow",
bold=True,
),
click.style(fix_utf8("..."), bold=True),
)
st.console.print(
f"[bold]Adding [green]{pkg_requirement.name}[/green][/bold] to Pipfile's [yellow]\\{pipfile_sections}[/yellow] ..."
)
# Add the package to the Pipfile.
if index_url:
@@ -2433,7 +2425,7 @@ def do_install(
)
)
# ok has a nice v in front, should do something similir with rich
st.update(
st.console.print(
environments.PIPENV_SPINNER_OK_TEXT.format("Installation Succeeded")
)
# Update project settings with pre preference.
+8 -6
View File
@@ -925,13 +925,13 @@ def resolve(cmd, st, project):
continue
err += line
if is_verbose:
st.update(line.rstrip())
st.console.print(line.rstrip())
c.wait()
returncode = c.poll()
out = c.stdout.read()
if returncode != 0:
st.update(environments.PIPENV_SPINNER_FAIL_TEXT.format("Locking Failed!"))
st.console.print(environments.PIPENV_SPINNER_FAIL_TEXT.format("Locking Failed!"))
echo(out.strip(), err=True)
if not is_verbose:
echo(err, err=True)
@@ -1031,7 +1031,7 @@ def venv_resolve_deps(
# we now download those requirements / make temporary folders to perform
# dependency resolution on them, so we are including this step inside the
# spinner context manager for the UX improvement
st.update("Building requirements...")
st.console.print("Building requirements...")
deps = convert_deps_to_pip(deps, project, include_index=True)
constraints = set(deps)
with tempfile.NamedTemporaryFile(
@@ -1040,14 +1040,16 @@ def venv_resolve_deps(
constraints_file.write(str("\n".join(constraints)))
cmd.append("--constraints-file")
cmd.append(constraints_file.name)
st.update("Resolving dependencies...")
st.console.print("Resolving dependencies...")
c = resolve(cmd, st, project=project)
if c.returncode == 0:
st.update(environments.PIPENV_SPINNER_OK_TEXT.format("Success!"))
st.console.print(environments.PIPENV_SPINNER_OK_TEXT.format("Success!"))
if not project.s.is_verbose() and c.stderr.strip():
click.echo(click.style(f"Warning: {c.stderr.strip()}"), err=True)
else:
st.update(environments.PIPENV_SPINNER_FAIL_TEXT.format("Locking Failed!"))
st.console.print(
environments.PIPENV_SPINNER_FAIL_TEXT.format("Locking Failed!")
)
click.echo(f"Output: {c.stdout.strip()}", err=True)
click.echo(f"Error: {c.stderr.strip()}", err=True)
try:
+1 -1
View File
@@ -9,4 +9,4 @@ def test_update_outdated_with_outdated_package(pipenv_instance_private_pypi, cmd
p.pipenv(f"install {cmd_option} {package_name}==1.11")
c = p.pipenv("update --outdated")
assert isinstance(c.exception, SystemExit)
assert c.stdout_bytes.decode("utf-8").startswith(f"Package '{package_name}' out-of-date:")
assert f"Package '{package_name}' out-of-date:" in c.stdout_bytes.decode("utf-8")