Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of error output #79

Merged
merged 1 commit into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jupyter_releaser/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def publish_assets(dist_dir, npm_token, npm_cmd, twine_cmd, dry_run, use_checkou
try:
util.run(f"{npm_cmd} {name}", cwd=dist_dir, quiet=True)
except CalledProcessError as e:
stderr = e.stderr.decode("utf-8")
stderr = e.stderr
if (
"EPUBLISHCONFLICT" in stderr
or "previously published versions" in stderr
Expand Down
4 changes: 2 additions & 2 deletions jupyter_releaser/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ def wrapped(cmd, **kwargs):
called += 1
if called == 0:
err = CalledProcessError(1, "foo")
err.stderr = "EPUBLISHCONFLICT".encode("UTF-8")
err.stderr = "EPUBLISHCONFLICT"
raise err

mock_run = mocker.patch("jupyter_releaser.util.run", wraps=wrapped)
Expand Down Expand Up @@ -559,7 +559,7 @@ def wrapped(cmd, **kwargs):
if cmd.startswith("npm publish --dry-run"):
called += 1
err = CalledProcessError(1, "foo")
err.stderr = "previously published versions".encode("UTF-8")
err.stderr = "previously published versions"
raise err

mocker.patch("jupyter_releaser.util.run", wraps=wrapped)
Expand Down
6 changes: 4 additions & 2 deletions jupyter_releaser/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ def _run_win(cmd, **kwargs):
log(output)
return output
except CalledProcessError as e:
e.output = e.output.decode("utf-8")
if quiet:
log("stderr:\n", e.stderr.decode("utf-8").strip(), "\n\n")
log("stdout:\n", e.output.decode("utf-8").strip(), "\n\n")
e.stderr = e.stderr.decode("utf-8")
log("stderr:\n", e.stderr.strip(), "\n\n")
log("stdout:\n", e.output.strip(), "\n\n")
raise e


Expand Down