Skip to content

Commit

Permalink
Merge pull request #352 from wdpypere/suppress_erros
Browse files Browse the repository at this point in the history
make suppressing error messages an option
  • Loading branch information
hajgato authored Oct 28, 2024
2 parents 1e2da47 + 7303410 commit 9443d42
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: install tox
Expand Down
13 changes: 10 additions & 3 deletions lib/vsc/utils/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,14 @@ def __init__(self, cmd=None, **kwargs):
@param use_shell: use the subshell
@param shell: change the shell
@param env: environment settings to pass on
@param post_exitcode: log errors on non zero exitcode (debug otherwise)
"""
self.input = kwargs.pop('input', None)
self.startpath = kwargs.pop('startpath', None)
self.use_shell = kwargs.pop('use_shell', self.USE_SHELL)
self.shell = kwargs.pop('shell', self.SHELL)
self.env = kwargs.pop('env', None)
self.post_exitcode = kwargs.pop('post_exitcode', True)

if kwargs.pop('disable_log', None):
self.log = DummyFunction() # No logging
Expand Down Expand Up @@ -440,8 +442,14 @@ def _post_exitcode(self):
cmd_ascii = ensure_ascii_string(self.cmd)
if not self._process_exitcode == 0:
shell_cmd_ascii = ensure_ascii_string(self._shellcmd)
self._post_exitcode_log_failure("_post_exitcode: problem occured with cmd %s: (shellcmd %s) output %s",
cmd_ascii, shell_cmd_ascii, self._process_output)
message = (
f"_post_exitcode: problem occured with cmd {cmd_ascii}:"
f"(shellcmd {shell_cmd_ascii}) output {self._process_output}"
)
if self.post_exitcode:
self._post_exitcode_log_failure(message)
else:
self.log.debug(message)
else:
self.log.debug("_post_exitcode: success cmd %s: output %s", cmd_ascii, self._process_output)

Expand Down Expand Up @@ -763,7 +771,6 @@ def _read_process(self, readsize=None):
class RunNoShellFile(RunNoShell, RunFile):
"""Popen to filehandle"""


class RunPty(Run):
"""Pty support (eg for screen sessions)"""
def _read_process(self, readsize=None):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from vsc.install.shared_setup import ag, kh, jt, sdw, wdp

PACKAGE = {
'version': '3.6.1',
'version': '3.6.2',
'author': [sdw, jt, ag, kh],
'maintainer': [sdw, jt, ag, kh, wdp],
'install_requires': [
Expand Down

0 comments on commit 9443d42

Please sign in to comment.