From ef53ca3345c5b1fad9b666fe3402275075837daa Mon Sep 17 00:00:00 2001 From: tjgalvin Date: Thu, 23 Nov 2023 15:46:36 +0800 Subject: [PATCH] test for stderr before printing (#212) * test for stderr before printing * bumped version / added to change log * changed to a different semver * corrected version --------- Co-authored-by: tgalvin --- CHANGELOG.md | 1 + spython/utils/terminal.py | 5 ++++- spython/version.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c53755..9daaa87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ The client here will eventually be released as "spython" (and eventually to singularity on pypi), and the versions here will coincide with these releases. ## [master](https://github.com/singularityhub/singularity-cli/tree/master) + - added check to enbsure stderr exists upon a non-zero return code when streaming (0.3.11) - exposed the stream type option, and ability to capture both stdout and stderr when stream=True (0.3.1) - dropping support for Singularity 2.x (0.3.0) - add comment out of STOPSIGNAL (0.2.14) diff --git a/spython/utils/terminal.py b/spython/utils/terminal.py index 0fee5c2..a8899e0 100644 --- a/spython/utils/terminal.py +++ b/spython/utils/terminal.py @@ -148,7 +148,10 @@ def stream_command( process.stdout.close() return_code = process.wait() if return_code: - print(process.stderr.read(), file=sys.stderr) + # Some situations may return process without an attached stderr object + # to read from + if process.stderr: + print(process.stderr.read(), file=sys.stderr) raise subprocess.CalledProcessError(return_code, cmd) diff --git a/spython/version.py b/spython/version.py index bfb48a0..100b811 100644 --- a/spython/version.py +++ b/spython/version.py @@ -5,7 +5,7 @@ # with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -__version__ = "0.3.1" +__version__ = "0.3.11" AUTHOR = "Vanessa Sochat" AUTHOR_EMAIL = "vsoch@users.noreply.github.com" NAME = "spython"