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

Commit846c05f

Browse files
authored
Merge pull request#96 from postgrespro/add_known_host-macos-fix
RemoteOperations add_known_host macos fix
2 parents90ab804 +4200b80 commit846c05f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

‎testgres/operations/remote_ops.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
importos
44
importsubprocess
55
importtempfile
6+
importplatform
67

78
# we support both pg8000 and psycopg2
89
try:
@@ -42,7 +43,8 @@ def cmdline(self):
4243

4344
classRemoteOperations(OsOperations):
4445
def__init__(self,conn_params:ConnectionParams):
45-
ifos.name!="posix":
46+
47+
ifnotplatform.system().lower()=="linux":
4648
raiseEnvironmentError("Remote operations are supported only on Linux!")
4749

4850
super().__init__(conn_params.username)
@@ -76,16 +78,14 @@ def close_ssh_tunnel(self):
7678
print("No active tunnel to close.")
7779

7880
defadd_known_host(self,host):
79-
cmd='ssh-keyscan -H %s >> /home/%s/.ssh/known_hosts'% (host,os.getlogin())
81+
known_hosts_path=os.path.expanduser("~/.ssh/known_hosts")
82+
cmd='ssh-keyscan -H %s >> %s'% (host,known_hosts_path)
83+
8084
try:
81-
subprocess.check_call(
82-
cmd,
83-
shell=True,
84-
)
85+
subprocess.check_call(cmd,shell=True)
8586
logging.info("Successfully added %s to known_hosts."%host)
8687
exceptsubprocess.CalledProcessErrorase:
87-
raiseExecUtilException(message="Failed to add %s to known_hosts. Error: %s"% (host,str(e)),command=cmd,
88-
exit_code=e.returncode,out=e.stderr)
88+
raiseException("Failed to add %s to known_hosts. Error: %s"% (host,str(e)))
8989

9090
defexec_command(self,cmd,wait_exit=False,verbose=False,expect_error=False,
9191
encoding=None,shell=True,text=False,input=None,stdin=None,stdout=None,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp