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

Commit6115461

Browse files
author
vshepard
committed
PBCKP-781 change defaukt vakue PG_PROBACKUP_S3_HTTPS on ON
1 parentcfa6d28 commit6115461

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
@@ -48,10 +48,10 @@ def __init__(self, conn_params: ConnectionParams):
4848
self.ssh_key=conn_params.ssh_key
4949
self.port=conn_params.port
5050
self.ssh_cmd= ["-o StrictHostKeyChecking=no"]
51-
ifself.ssh_key:
52-
self.ssh_cmd+= ["-i",self.ssh_key]
5351
ifself.port:
5452
self.ssh_cmd+= ["-p",self.port]
53+
ifself.ssh_key:
54+
self.ssh_cmd+= ["-i",self.ssh_key]
5555
self.remote=True
5656
self.username=conn_params.usernameorself.get_user()
5757
self.tunnel_process=None
@@ -283,6 +283,7 @@ 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+
# Because in scp we set up port using -P option instead -p
286287
scp_ssh_cmd= ['-P'ifx=='-p'elsexforxinself.ssh_cmd]
287288

288289
ifnottruncate:
@@ -302,12 +303,11 @@ def write(self, filename, data, truncate=False, binary=False, read_and_write=Fal
302303
tmp_file.write(data)
303304

304305
tmp_file.flush()
305-
# Because in scp we set up port using -P option
306306
scp_cmd= ['scp']+scp_ssh_cmd+ [tmp_file.name,f"{self.username}@{self.host}:{filename}"]
307307
subprocess.run(scp_cmd,check=True)
308-
309308
remote_directory=os.path.dirname(filename)
310-
mkdir_cmd= ['ssh']+scp_ssh_cmd+ [f"{self.username}@{self.host}",f"mkdir -p{remote_directory}"]
309+
310+
mkdir_cmd= ['ssh']+self.ssh_cmd+ [f"{self.username}@{self.host}",f'mkdir -p{remote_directory}']
311311
subprocess.run(mkdir_cmd,check=True)
312312

313313
os.remove(tmp_file.name)
@@ -385,9 +385,10 @@ def get_process_children(self, pid):
385385
# Database control
386386
defdb_connect(self,dbname,user,password=None,host="localhost",port=5432):
387387
"""
388-
EstablishedSSH tunnel andConnects to a PostgreSQL
388+
EstablishSSH tunnel andconnect to a PostgreSQL database.
389389
"""
390-
self.establish_ssh_tunnel(local_port=reserve_port(),remote_port=5432)
390+
self.establish_ssh_tunnel(local_port=port,remote_port=self.conn_params.port)
391+
391392
try:
392393
conn=pglib.connect(
393394
host=host,
@@ -396,6 +397,11 @@ def db_connect(self, dbname, user, password=None, host="localhost", port=5432):
396397
user=user,
397398
password=password,
398399
)
400+
print("Database connection established successfully.")
399401
returnconn
400402
exceptExceptionase:
401-
raiseException(f"Could not connect to the database. Error:{e}")
403+
print(f"Error connecting to the database:{str(e)}")
404+
ifself.tunnel_process:
405+
self.tunnel_process.terminate()
406+
print("SSH tunnel closed due to connection failure.")
407+
raise

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp