Skip to content

Commit 34ddbd5

Browse files
authored
Save information about origin exception and traceback in deserialize (#89)
Bump to 2.1.1
1 parent 2a2550a commit 34ddbd5

File tree

7 files changed

+17
-15
lines changed

7 files changed

+17
-15
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
install:
8585
- *upgrade_python_toolset
8686
- *install_deps
87-
- pip install --upgrade "mypy >= 0.620"
87+
- pip install --upgrade "mypy >= 0.641"
8888
script:
8989
- mypy --strict exec_helpers
9090

exec_helpers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"ExecResult",
5050
)
5151

52-
__version__ = "2.1.0"
52+
__version__ = "2.1.1"
5353
__author__ = "Alexey Stepanov"
5454
__author_email__ = "penguinolog@gmail.com"
5555
__maintainers__ = {

exec_helpers/_ssh_client_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ def poll_streams() -> None:
658658
if stderr and interface.recv_stderr_ready():
659659
result.read_stderr(src=stderr, log=self.logger, verbose=verbose)
660660

661-
@threaded.threadpooled # type: ignore
661+
@threaded.threadpooled
662662
def poll_pipes(stop: threading.Event) -> None:
663663
"""Polling task for FIFO buffers.
664664
@@ -816,7 +816,7 @@ def execute_together(
816816
.. versionchanged:: 1.2.0 log_mask_re regex rule for masking cmd
817817
"""
818818

819-
@threaded.threadpooled # type: ignore
819+
@threaded.threadpooled
820820
def get_result(remote: "SSHClientBase") -> exec_result.ExecResult:
821821
"""Get result from remote call."""
822822
async_result = remote.execute_async(command, **kwargs) # type: SshExecuteAsyncResult

exec_helpers/exec_result.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,14 @@ def __deserialize(self, fmt: str) -> typing.Any:
365365
return json.loads(self.stdout_str, encoding="utf-8")
366366
elif fmt == "yaml":
367367
return yaml.safe_load(self.stdout_str)
368-
except Exception:
369-
tmpl = " stdout is not valid {fmt}:\n" "{{stdout!r}}\n".format(fmt=fmt)
370-
logger.exception(self.cmd + tmpl.format(stdout=self.stdout_str)) # pylint: disable=logging-not-lazy
371-
raise exceptions.DeserializeValueError(self.cmd + tmpl.format(stdout=self.stdout_brief))
368+
except Exception as e:
369+
tmpl = "{{self.cmd}} stdout is not valid {fmt}:\n" "{{stdout!r}}\n".format(fmt=fmt)
370+
logger.exception(tmpl.format(self=self, stdout=self.stdout_str)) # pylint: disable=logging-not-lazy
371+
372+
raise exceptions.DeserializeValueError(tmpl.format(self=self, stdout=self.stdout_brief)).with_traceback(
373+
e.__traceback__
374+
) from e
375+
372376
msg = "{fmt} deserialize target is not implemented".format(fmt=fmt)
373377
logger.error(msg)
374378
raise NotImplementedError(msg)

exec_helpers/ssh_auth.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,13 @@ def __ne__(self, other: typing.Any) -> bool:
205205

206206
def __deepcopy__(self, memo: typing.Any) -> "SSHAuth":
207207
"""Helper for copy.deepcopy."""
208-
return self.__class__( # type: ignore
208+
return self.__class__(
209209
username=self.username, password=self.__password, key=self.__key, keys=copy.deepcopy(self.__keys)
210210
)
211211

212212
def __copy__(self) -> "SSHAuth":
213213
"""Copy self."""
214-
return self.__class__( # type: ignore
215-
username=self.username, password=self.__password, key=self.__key, keys=self.__keys
216-
)
214+
return self.__class__(username=self.username, password=self.__password, key=self.__key, keys=self.__keys)
217215

218216
def __repr__(self) -> str:
219217
"""Representation for debug purposes."""

exec_helpers/subprocess_runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,12 @@ def _exec_command(
145145
.. versionadded:: 1.2.0
146146
"""
147147

148-
@threaded.threadpooled # type: ignore
148+
@threaded.threadpooled
149149
def poll_stdout() -> None:
150150
"""Sync stdout poll."""
151151
result.read_stdout(src=stdout, log=logger, verbose=verbose)
152152

153-
@threaded.threadpooled # type: ignore
153+
@threaded.threadpooled
154154
def poll_stderr() -> None:
155155
"""Sync stderr poll."""
156156
result.read_stderr(src=stderr, log=logger, verbose=verbose)

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,6 @@ commands = pipdeptree
147147

148148
[testenv:mypy]
149149
deps =
150-
mypy>=0.630
150+
mypy>=0.641
151151
-r{toxinidir}/CI_REQUIREMENTS.txt
152152
commands = mypy --strict exec_helpers

0 commit comments

Comments
 (0)