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

Commit94215a2

Browse files
committed
Merge branch 'master' into multihost-catchup
2 parents5707835 +4543f80 commit94215a2

File tree

2 files changed

+5
-29
lines changed

2 files changed

+5
-29
lines changed

‎testgres/node.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ def __init__(self, name=None, base_dir=None, port=None, conn_params: ConnectionP
157157

158158
self.host=self.os_ops.host
159159
self.port=portorreserve_port()
160+
160161
self.ssh_key=self.os_ops.ssh_key
161162

162163
# defaults for __exit__()

‎testgres/operations/remote_ops.py

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
importgetpass
22
importos
3-
importsocket
3+
importlogging
4+
importplatform
45
importsubprocess
56
importtempfile
6-
importplatform
77

88
# we support both pg8000 and psycopg2
99
try:
@@ -55,35 +55,10 @@ def __init__(self, conn_params: ConnectionParams):
5555
self.remote=True
5656
self.username=conn_params.usernameorgetpass.getuser()
5757
self.ssh_dest=f"{self.username}@{self.host}"ifconn_params.usernameelseself.host
58-
#self.add_known_host(self.host)
59-
self.tunnel_process=None
60-
self.tunnel_port=None
6158

6259
def__enter__(self):
6360
returnself
6461

65-
def__exit__(self,exc_type,exc_val,exc_tb):
66-
self.close_ssh_tunnel()
67-
68-
@staticmethod
69-
defis_port_open(host,port):
70-
withsocket.socket(socket.AF_INET,socket.SOCK_STREAM)assock:
71-
sock.settimeout(1)# Таймаут для попытки соединения
72-
try:
73-
sock.connect((host,port))
74-
returnTrue
75-
exceptsocket.error:
76-
returnFalse
77-
78-
defclose_ssh_tunnel(self):
79-
ifself.tunnel_process:
80-
self.tunnel_process.terminate()
81-
self.tunnel_process.wait()
82-
print("SSH tunnel closed.")
83-
delself.tunnel_process
84-
else:
85-
print("No active tunnel to close.")
86-
8762
defexec_command(self,cmd,wait_exit=False,verbose=False,expect_error=False,
8863
encoding=None,shell=True,text=False,input=None,stdin=None,stdout=None,
8964
stderr=None,get_process=None,timeout=None):
@@ -94,9 +69,9 @@ def exec_command(self, cmd, wait_exit=False, verbose=False, expect_error=False,
9469
"""
9570
ssh_cmd= []
9671
ifisinstance(cmd,str):
97-
ssh_cmd= ['ssh']+self.ssh_args+ [self.ssh_dest,cmd]
72+
ssh_cmd= ['ssh',self.ssh_dest]+self.ssh_args+ [cmd]
9873
elifisinstance(cmd,list):
99-
ssh_cmd= ['ssh']+self.ssh_args+[self.ssh_dest]+cmd
74+
ssh_cmd= ['ssh',self.ssh_dest]+self.ssh_args+cmd
10075
process=subprocess.Popen(ssh_cmd,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
10176
ifget_process:
10277
returnprocess

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp