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

Commitafb4a3d

Browse files
Merge remote-tracking branch 'origin/D20250301_01--os_ops-exec_command' into D20250226_001--ci_and_ssh
2 parentse245e23 +d843df6 commitafb4a3d

File tree

5 files changed

+38
-6
lines changed

5 files changed

+38
-6
lines changed

‎testgres/operations/local_ops.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ def exec_command(self, cmd, wait_exit=False, verbose=False, expect_error=False,
135135
RaiseError.UtilityExitedWithNonZeroCode(
136136
cmd=cmd,
137137
exit_code=process.returncode,
138+
msg_arg=errororoutput,
138139
error=error,
139140
out=output)
140141

‎testgres/operations/raise_error.py‎

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
from ..exceptionsimportExecUtilException
2+
from .helpersimportHelpers
23

34

45
classRaiseError:
56
@staticmethod
6-
defUtilityExitedWithNonZeroCode(cmd,exit_code,error,out):
7+
defUtilityExitedWithNonZeroCode(cmd,exit_code,msg_arg,error,out):
78
asserttype(exit_code)==int# noqa: E721
89

10+
msg_arg_s=__class__._TranslateDataIntoString(msg_arg)
11+
asserttype(msg_arg_s)==str# noqa: E721
12+
13+
msg_arg_s=msg_arg_s.strip()
14+
ifmsg_arg_s=="":
15+
msg_arg_s="#no_error_message"
16+
17+
message="Utility exited with non-zero code ("+str(exit_code)+"). Error: `"+msg_arg_s+"`"
918
raiseExecUtilException(
10-
message="Utility exited with non-zero code.",
19+
message=message,
1120
command=cmd,
1221
exit_code=exit_code,
1322
out=out,
@@ -25,3 +34,24 @@ def CommandExecutionError(cmd, exit_code, message, error, out):
2534
exit_code=exit_code,
2635
out=out,
2736
error=error)
37+
38+
@staticmethod
39+
def_TranslateDataIntoString(data):
40+
ifdataisNone:
41+
return""
42+
43+
iftype(data)==bytes:# noqa: E721
44+
return__class__._TranslateDataIntoString__FromBinary(data)
45+
46+
returnstr(data)
47+
48+
@staticmethod
49+
def_TranslateDataIntoString__FromBinary(data):
50+
asserttype(data)==bytes# noqa: E721
51+
52+
try:
53+
returndata.decode(Helpers.GetDefaultEncoding())
54+
exceptUnicodeDecodeError:
55+
pass
56+
57+
return"#cannot_decode_text"

‎testgres/operations/remote_ops.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ def exec_command(self, cmd, wait_exit=False, verbose=False, expect_error=False,
126126
RaiseError.UtilityExitedWithNonZeroCode(
127127
cmd=cmd,
128128
exit_code=process.returncode,
129+
msg_arg=error,
129130
error=error,
130131
out=output)
131132

@@ -180,7 +181,7 @@ def is_executable(self, file):
180181
exit_status,
181182
file)
182183

183-
RaiseError.UtilityExitedWithNonZeroCode(
184+
RaiseError.CommandExecutionError(
184185
cmd=command,
185186
exit_code=exit_status,
186187
msg_arg=errMsg,

‎tests/test_local.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_exec_command_failure(self):
4040
try:
4141
self.operations.exec_command(cmd,wait_exit=True,shell=True)
4242
exceptExecUtilExceptionase:
43-
asserte.message=="Utility exited with non-zero code."
43+
asserte.message=="Utility exited with non-zero code (127). Error: `/bin/sh: 1: nonexistent_command: not found`"
4444
asserttype(e.error)==bytes# noqa: E721
4545
asserte.error.strip()==b"/bin/sh: 1: nonexistent_command: not found"
4646
break

‎tests/test_remote.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_exec_command_failure(self):
3838
try:
3939
self.operations.exec_command(cmd,verbose=True,wait_exit=True)
4040
exceptExecUtilExceptionase:
41-
asserte.message=="Utility exited with non-zero code."
41+
asserte.message=="Utility exited with non-zero code (127). Error: `bash: line 1: nonexistent_command: command not found`"
4242
asserttype(e.error)==bytes# noqa: E721
4343
asserte.error.strip()==b"bash: line 1: nonexistent_command: command not found"
4444
break
@@ -109,7 +109,7 @@ def test_makedirs_and_rmdirs_failure(self):
109109
try:
110110
self.operations.rmdirs(path,verbose=True)
111111
exceptExecUtilExceptionase:
112-
asserte.message=="Utility exited with non-zero code."
112+
asserte.message=="Utility exited with non-zero code (1). Error: `rm: cannot remove '/root/test_dir': Permission denied`"
113113
asserttype(e.error)==bytes# noqa: E721
114114
asserte.error.strip()==b"rm: cannot remove '/root/test_dir': Permission denied"
115115
break

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp