Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit98b0286

Browse files
authored
Ignore error teardown (#142)
1 parent1d1d3f0 commit98b0286

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

‎testgres/node.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,8 @@ def _try_shutdown(self, max_attempts, with_force=False):
359359
# The node has already stopped
360360
pass
361361

362-
# Check that node stopped
363-
p_status_output=self.os_ops.exec_command(f'ps -p{node_pid}',shell=True,expect_error=True).decode('utf-8')
362+
# Check that node stopped - print only column pid without headers
363+
p_status_output=self.os_ops.exec_command(f'ps -o pid= -p{node_pid}',shell=True,ignore_errors=True).decode('utf-8')
364364
ifp_status_outputandstr(node_pid)inp_status_output:
365365
eprint(f'Failed to stop node{self.name}.')
366366
else:

‎testgres/operations/local_ops.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,15 @@ def _run_command(self, cmd, shell, input, stdin, stdout, stderr, get_process, ti
107107
raiseExecUtilException("Command timed out after {} seconds.".format(timeout))
108108

109109
defexec_command(self,cmd,wait_exit=False,verbose=False,expect_error=False,encoding=None,shell=False,
110-
text=False,input=None,stdin=None,stdout=None,stderr=None,get_process=False,timeout=None):
110+
text=False,input=None,stdin=None,stdout=None,stderr=None,get_process=False,timeout=None,
111+
ignore_errors=False):
111112
"""
112113
Execute a command in a subprocess and handle the output based on the provided parameters.
113114
"""
114115
process,output,error=self._run_command(cmd,shell,input,stdin,stdout,stderr,get_process,timeout,encoding)
115116
ifget_process:
116117
returnprocess
117-
if(process.returncode!=0orhas_errors(output=output,error=error))andnotexpect_error:
118+
ifnotignore_errorsand ((process.returncode!=0orhas_errors(output=output,error=error))andnotexpect_error):
118119
self._raise_exec_exception('Utility exited with non-zero code. Error `{}`',cmd,process.returncode,errororoutput)
119120

120121
ifverbose:

‎testgres/operations/remote_ops.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def __enter__(self):
6060

6161
defexec_command(self,cmd,wait_exit=False,verbose=False,expect_error=False,
6262
encoding=None,shell=True,text=False,input=None,stdin=None,stdout=None,
63-
stderr=None,get_process=None,timeout=None):
63+
stderr=None,get_process=None,timeout=None,ignore_errors=False):
6464
"""
6565
Execute a command in the SSH session.
6666
Args:
@@ -98,7 +98,7 @@ def exec_command(self, cmd, wait_exit=False, verbose=False, expect_error=False,
9898
markerinerrorformarkerin ['error','Permission denied','fatal','No such file or directory']
9999
)
100100

101-
iferror_found:
101+
ifnotignore_errorsanderror_found:
102102
ifisinstance(error,bytes):
103103
message=b"Utility exited with non-zero code. Error: "+error
104104
else:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp