Skip to content

Commit

Permalink
Merge pull request #4 from narrenorg/fix/printing-to-stderr
Browse files Browse the repository at this point in the history
Print both STDOUT and STDERR if they both exist
  • Loading branch information
petarnikolovski committed Oct 4, 2021
2 parents d229dd7 + 1f9aa75 commit 1a58b45
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.4.6] - 2021-10-04
### Fixed
- STDERR gets printed even in the case when it is only emitted as a warning, narrenschiff now defaults to printing both STDOUT and STDERR if both exists

## [3.4.5] - 2021-09-13
### Fixed
- Security issue `[B603:subprocess_without_shell_equals_true]` (Severity: Low)
Expand All @@ -26,7 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [3.4.1] - 2021-09-02
### Fixed
- STDOUT gets printed event in the case of error, narrenschiff now defaults to printing STDOUT only if STDERR is missing from shell subprocess
- STDOUT gets printed even in the case of error, narrenschiff now defaults to printing STDOUT only if STDERR is missing from shell subprocess
- Test package is not a part of the distribution anymore

## [3.4.0] - 2021-08-21
Expand Down Expand Up @@ -216,6 +220,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Cannot load keys and salts from paths that use `~`

[3.4.6]: https://github.com/narrenorg/narrenschiff/compare/3.4.5...3.4.6
[3.4.5]: https://github.com/narrenorg/narrenschiff/compare/3.4.4...3.4.5
[3.4.4]: https://github.com/narrenorg/narrenschiff/compare/3.4.3...3.4.4
[3.4.3]: https://github.com/narrenorg/narrenschiff/compare/3.4.2...3.4.3
Expand Down
2 changes: 1 addition & 1 deletion narrenschiff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# limitations under the License.


__version__ = "3.4.5"
__version__ = "3.4.6"
10 changes: 8 additions & 2 deletions narrenschiff/modules/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,17 @@ def subprocess(self, cmd):
stderr=subprocess.PIPE
)

output = process.stderr if process.stderr else process.stdout
if process.stdout and process.stderr:
stdout = process.stdout.decode('utf-8')
stderr = process.stderr.decode('utf-8')
output = f'{stderr}\n{stdout}'
else:
output = process.stderr if process.stderr else process.stdout
output = output.decode('utf-8')

logger.info(f'Command "{cmd}" executed')

return output.decode('utf-8'), process.returncode
return output, process.returncode

def echo(self, output, rc):
"""
Expand Down

0 comments on commit 1a58b45

Please sign in to comment.