diff --git a/CHANGELOG.md b/CHANGELOG.md index 5adc0a0..dc37b52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.2.3 +- Bugfix: `exit_code` was not being set when using `stream=True`. This was fixed by calling `Popen.poll()` + ## v0.2.2 - `exit_code` is now a property, `status_code` is still supported but will be deprecated diff --git a/Makefile b/Makefile index 417d6e1..032e151 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,7 @@ +pybuild: + rm -rf dist/* + python setup.py sdist bdist_wheel + upload: twine check dist/* twine upload dist/* diff --git a/setup.py b/setup.py index 6a5b544..8564aa8 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name='soldier', - version='0.2.2', + version='0.2.3', author='Yash Mehrotra', author_email='yashmehrotra95@gmail.com', packages=['soldier'], diff --git a/soldier/soldier.py b/soldier/soldier.py index 8f31eec..e6aa58a 100644 --- a/soldier/soldier.py +++ b/soldier/soldier.py @@ -161,6 +161,7 @@ def _set_communication_params(self, wait=False): sys.stdout.write(line) output += line self._output = output + self._err = self._process.stderr.read() else: self._output, self._err = self._process.communicate(self._output) @@ -168,6 +169,7 @@ def _set_communication_params(self, wait=False): if self._err and not self._suppress_std_err: print(self._err) + self._process.poll() self._exit_code = self._process.returncode def _finish(self): diff --git a/tests/test_streaming.py b/tests/test_streaming.py index e4f7370..cabd6b6 100644 --- a/tests/test_streaming.py +++ b/tests/test_streaming.py @@ -25,4 +25,9 @@ def test_stream(self): s = soldier.run('ls') command_output = s.output.strip().split('\n') + assert stream_output == command_output + + def test_stream_exit_code(self): + s = soldier.run('echo hello > /dev/null', stream=True) + assert s.exit_code == 0