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

Commit4f5e23c

Browse files
author
vshepard
committed
Update establish_ssh_tunnel
1 parent013b359 commit4f5e23c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

‎testgres/operations/remote_ops.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ def is_port_open(host, port):
7474
exceptsocket.error:
7575
returnFalse
7676

77-
defestablish_ssh_tunnel(self,local_port,remote_port):
77+
defestablish_ssh_tunnel(self,local_port,remote_port,host='localhost'):
7878
"""
7979
Establish an SSH tunnel from a local port to a remote PostgreSQL port.
8080
"""
81-
ssh_cmd= ['-N','-L',f"{local_port}:localhost:{remote_port}"]
81+
ssh_cmd= ['-N','-L',f"{local_port}:{host}:{remote_port}"]
8282
self.tunnel_process=self.exec_command(ssh_cmd,get_process=True,timeout=300)
8383
timeout=10
8484
start_time=time.time()
@@ -410,7 +410,7 @@ def db_connect(self, dbname, user, password=None, host="localhost", port=5432):
410410
"""
411411
local_port=reserve_port()
412412
self.tunnel_port=local_port
413-
self.establish_ssh_tunnel(local_port=local_port,remote_port=port)
413+
self.establish_ssh_tunnel(local_port=local_port,remote_port=port,host=host)
414414
try:
415415
conn=pglib.connect(
416416
host=host,
@@ -423,8 +423,8 @@ def db_connect(self, dbname, user, password=None, host="localhost", port=5432):
423423
print("Database connection established successfully.")
424424
returnconn
425425
exceptExceptionase:
426-
print(f"Error connecting to the database:{str(e)}")
426+
print(f"!!!Error connecting to the database:{str(e)}")
427427
ifself.tunnel_process:
428428
self.tunnel_process.terminate()
429-
print("SSH tunnel closed due to connection failure.")
429+
print("!!!SSH tunnel closed due to connection failure.")
430430
raise

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp