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

Commitb0f90d9

Browse files
[RemoteOperations] A call of mktemp is fixed (#202)
When we define a template we have to use "-t" option. It forces mktemp to return a path instead name.The following methods of RemoteOperations are fixed: - mkdtemp - mkstemp
1 parent22826e0 commitb0f90d9

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

‎testgres/operations/remote_ops.py

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -247,32 +247,42 @@ def mkdtemp(self, prefix=None):
247247
- prefix (str): The prefix of the temporary directory name.
248248
"""
249249
ifprefix:
250-
command= ["ssh"]+self.ssh_args+ [self.ssh_dest,f"mktemp -d{prefix}XXXXX"]
250+
command= ["mktemp","-d","-t",prefix+"XXXXX"]
251251
else:
252-
command= ["ssh"]+self.ssh_args+ [self.ssh_dest,"mktemp-d"]
252+
command= ["mktemp","-d"]
253253

254-
result=subprocess.run(command,stdout=subprocess.PIPE,stderr=subprocess.PIPE,text=True)
254+
exit_status,result,error=self.exec_command(command,verbose=True,encoding=get_default_encoding(),ignore_errors=True)
255255

256-
ifresult.returncode==0:
257-
temp_dir=result.stdout.strip()
258-
ifnotos.path.isabs(temp_dir):
259-
temp_dir=os.path.join('/home',self.username,temp_dir)
260-
returntemp_dir
261-
else:
262-
raiseExecUtilException(f"Could not create temporary directory. Error:{result.stderr}")
256+
asserttype(result)==str# noqa: E721
257+
asserttype(error)==str# noqa: E721
258+
259+
ifexit_status!=0:
260+
raiseExecUtilException("Could not create temporary directory. Error code: {0}. Error message: {1}".format(exit_status,error))
261+
262+
temp_dir=result.strip()
263+
returntemp_dir
263264

264265
defmkstemp(self,prefix=None):
266+
"""
267+
Creates a temporary file in the remote server.
268+
Args:
269+
- prefix (str): The prefix of the temporary directory name.
270+
"""
265271
ifprefix:
266-
temp_dir=self.exec_command("mktemp {}XXXXX".format(prefix),encoding=get_default_encoding())
272+
command=["mktemp","-t",prefix+"XXXXX"]
267273
else:
268-
temp_dir=self.exec_command("mktemp",encoding=get_default_encoding())
274+
command=["mktemp"]
269275

270-
iftemp_dir:
271-
ifnotos.path.isabs(temp_dir):
272-
temp_dir=os.path.join('/home',self.username,temp_dir.strip())
273-
returntemp_dir
274-
else:
275-
raiseExecUtilException("Could not create temporary directory.")
276+
exit_status,result,error=self.exec_command(command,verbose=True,encoding=get_default_encoding(),ignore_errors=True)
277+
278+
asserttype(result)==str# noqa: E721
279+
asserttype(error)==str# noqa: E721
280+
281+
ifexit_status!=0:
282+
raiseExecUtilException("Could not create temporary file. Error code: {0}. Error message: {1}".format(exit_status,error))
283+
284+
temp_file=result.strip()
285+
returntemp_file
276286

277287
defcopytree(self,src,dst):
278288
ifnotos.path.isabs(dst):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp