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

Commitcfa6d28

Browse files
author
vshepard
committed
Add port to scp command
1 parent1e20cdb commitcfa6d28

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

‎testgres/operations/remote_ops.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,10 @@ def write(self, filename, data, truncate=False, binary=False, read_and_write=Fal
283283
mode="r+b"ifbinaryelse"r+"
284284

285285
withtempfile.NamedTemporaryFile(mode=mode,delete=False)astmp_file:
286+
scp_ssh_cmd= ['-P'ifx=='-p'elsexforxinself.ssh_cmd]
287+
286288
ifnottruncate:
287-
scp_cmd= ['scp']+self.ssh_cmd+ [f"{self.username}@{self.host}:{filename}",tmp_file.name]
289+
scp_cmd= ['scp']+scp_ssh_cmd+ [f"{self.username}@{self.host}:{filename}",tmp_file.name]
288290
subprocess.run(scp_cmd,check=False)# The file might not exist yet
289291
tmp_file.seek(0,os.SEEK_END)
290292

@@ -300,11 +302,12 @@ def write(self, filename, data, truncate=False, binary=False, read_and_write=Fal
300302
tmp_file.write(data)
301303

302304
tmp_file.flush()
303-
scp_cmd= ['scp']+self.ssh_cmd+ [tmp_file.name,f"{self.username}@{self.host}:{filename}"]
305+
# Because in scp we set up port using -P option
306+
scp_cmd= ['scp']+scp_ssh_cmd+ [tmp_file.name,f"{self.username}@{self.host}:{filename}"]
304307
subprocess.run(scp_cmd,check=True)
305308

306309
remote_directory=os.path.dirname(filename)
307-
mkdir_cmd= ['ssh']+self.ssh_cmd+ [f"{self.username}@{self.host}",f"mkdir -p{remote_directory}"]
310+
mkdir_cmd= ['ssh']+scp_ssh_cmd+ [f"{self.username}@{self.host}",f"mkdir -p{remote_directory}"]
308311
subprocess.run(mkdir_cmd,check=True)
309312

310313
os.remove(tmp_file.name)

‎testgres/utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ def execute_utility(args, logfile=None, verbose=False):
7474

7575
# write new log entry if possible
7676
iflogfile:
77-
ifnottconf.os_ops.path_exists(logfile):
78-
tconf.os_ops.touch(logfile)
7977
try:
8078
tconf.os_ops.write(filename=logfile,data=args,truncate=True)
8179
ifout:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp