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

Commitcd0b5f8

Browse files
Code normalization
- New debug checks- Normalization
1 parent7b70e9e commitcd0b5f8

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

‎testgres/operations/local_ops.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,25 +86,32 @@ def _run_command__generic(self, cmd, shell, input, stdin, stdout, stderr, get_pr
8686
ifnotget_process:
8787
input_prepared=Helpers.PrepareProcessInput(input,encoding)# throw
8888

89+
assertinput_preparedisNoneor (type(input_prepared)==bytes)# noqa: E721
90+
8991
process=subprocess.Popen(
9092
cmd,
9193
shell=shell,
9294
stdin=stdinorsubprocess.PIPEifinputisnotNoneelseNone,
9395
stdout=stdoutorsubprocess.PIPE,
9496
stderr=stderrorsubprocess.PIPE,
9597
)
98+
assertnot (processisNone)
9699
ifget_process:
97100
returnprocess,None,None
98101
try:
99102
output,error=process.communicate(input=input_prepared,timeout=timeout)
100-
ifencoding:
101-
output=output.decode(encoding)
102-
error=error.decode(encoding)
103-
returnprocess,output,error
104103
exceptsubprocess.TimeoutExpired:
105104
process.kill()
106105
raiseExecUtilException("Command timed out after {} seconds.".format(timeout))
107106

107+
asserttype(output)==bytes# noqa: E721
108+
asserttype(error)==bytes# noqa: E721
109+
110+
ifencoding:
111+
output=output.decode(encoding)
112+
error=error.decode(encoding)
113+
returnprocess,output,error
114+
108115
def_run_command(self,cmd,shell,input,stdin,stdout,stderr,get_process,timeout,encoding):
109116
"""Execute a command and return the process and its output."""
110117
ifos.name=='nt'andstdoutisNone:# Windows

‎testgres/operations/remote_ops.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,15 @@ def exec_command(self, cmd, wait_exit=False, verbose=False, expect_error=False,
7575
ifnotget_process:
7676
input_prepared=Helpers.PrepareProcessInput(input,encoding)# throw
7777

78+
assertinput_preparedisNoneor (type(input_prepared)==bytes)# noqa: E721
79+
7880
ssh_cmd= []
7981
ifisinstance(cmd,str):
8082
ssh_cmd= ['ssh',self.ssh_dest]+self.ssh_args+ [cmd]
8183
elifisinstance(cmd,list):
8284
ssh_cmd= ['ssh',self.ssh_dest]+self.ssh_args+cmd
8385
process=subprocess.Popen(ssh_cmd,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
86+
assertnot (processisNone)
8487
ifget_process:
8588
returnprocess
8689

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp