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

Commitf786b87

Browse files
author
vshepard
committed
PBCKP-781 change defaukt vakue PG_PROBACKUP_S3_HTTPS on ON
1 parentd08325b commitf786b87

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

‎testgres/operations/remote_ops.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ def __init__(self, conn_params: ConnectionParams):
5050
self.ssh_key=conn_params.ssh_key
5151
self.port=conn_params.port
5252
self.ssh_cmd= ["-o StrictHostKeyChecking=no"]
53-
ifself.ssh_key:
54-
self.ssh_cmd+= ["-i",self.ssh_key]
5553
ifself.port:
5654
self.ssh_cmd+= ["-p",self.port]
55+
ifself.ssh_key:
56+
self.ssh_cmd+= ["-i",self.ssh_key]
5757
self.remote=True
5858
self.username=conn_params.usernameorself.get_user()
5959
self.tunnel_process=None
@@ -285,6 +285,7 @@ def write(self, filename, data, truncate=False, binary=False, read_and_write=Fal
285285
mode="r+b"ifbinaryelse"r+"
286286

287287
withtempfile.NamedTemporaryFile(mode=mode,delete=False)astmp_file:
288+
# Because in scp we set up port using -P option instead -p
288289
scp_ssh_cmd= ['-P'ifx=='-p'elsexforxinself.ssh_cmd]
289290

290291
ifnottruncate:
@@ -304,12 +305,11 @@ def write(self, filename, data, truncate=False, binary=False, read_and_write=Fal
304305
tmp_file.write(data)
305306

306307
tmp_file.flush()
307-
# Because in scp we set up port using -P option
308308
scp_cmd= ['scp']+scp_ssh_cmd+ [tmp_file.name,f"{self.username}@{self.host}:{filename}"]
309309
subprocess.run(scp_cmd,check=True)
310-
311310
remote_directory=os.path.dirname(filename)
312-
mkdir_cmd= ['ssh']+scp_ssh_cmd+ [f"{self.username}@{self.host}",f"mkdir -p{remote_directory}"]
311+
312+
mkdir_cmd= ['ssh']+self.ssh_cmd+ [f"{self.username}@{self.host}",f'mkdir -p{remote_directory}']
313313
subprocess.run(mkdir_cmd,check=True)
314314

315315
os.remove(tmp_file.name)
@@ -387,9 +387,10 @@ def get_process_children(self, pid):
387387
# Database control
388388
defdb_connect(self,dbname,user,password=None,host="localhost",port=5432):
389389
"""
390-
EstablishedSSH tunnel andConnects to a PostgreSQL
390+
EstablishSSH tunnel andconnect to a PostgreSQL database.
391391
"""
392-
self.establish_ssh_tunnel(local_port=reserve_port(),remote_port=5432)
392+
self.establish_ssh_tunnel(local_port=port,remote_port=self.conn_params.port)
393+
393394
try:
394395
conn=pglib.connect(
395396
host=host,
@@ -398,6 +399,11 @@ def db_connect(self, dbname, user, password=None, host="localhost", port=5432):
398399
user=user,
399400
password=password,
400401
)
402+
print("Database connection established successfully.")
401403
returnconn
402404
exceptExceptionase:
403-
raiseException(f"Could not connect to the database. Error:{e}")
405+
print(f"Error connecting to the database:{str(e)}")
406+
ifself.tunnel_process:
407+
self.tunnel_process.terminate()
408+
print("SSH tunnel closed due to connection failure.")
409+
raise

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp