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

RemoteOperations add_known_host macos fix#96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
demonolock merged 1 commit intomasterfromadd_known_host-macos-fix
Nov 23, 2023
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletionstestgres/operations/remote_ops.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@
import os
import subprocess
import tempfile
import platform

# we support both pg8000 and psycopg2
try:
Expand DownExpand Up@@ -42,7 +43,8 @@ def cmdline(self):

class RemoteOperations(OsOperations):
def __init__(self, conn_params: ConnectionParams):
if os.name != "posix":

if not platform.system().lower() == "linux":
raise EnvironmentError("Remote operations are supported only on Linux!")

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

def add_known_host(self, host):
cmd = 'ssh-keyscan -H %s >> /home/%s/.ssh/known_hosts' % (host, os.getlogin())
known_hosts_path = os.path.expanduser("~/.ssh/known_hosts")
cmd = 'ssh-keyscan -H %s >> %s' % (host, known_hosts_path)

try:
subprocess.check_call(
cmd,
shell=True,
)
subprocess.check_call(cmd, shell=True)
logging.info("Successfully added %s to known_hosts." % host)
except subprocess.CalledProcessError as e:
raise ExecUtilException(message="Failed to add %s to known_hosts. Error: %s" % (host, str(e)), command=cmd,
exit_code=e.returncode, out=e.stderr)
raise Exception("Failed to add %s to known_hosts. Error: %s" % (host, str(e)))

def exec_command(self, cmd, wait_exit=False, verbose=False, expect_error=False,
encoding=None, shell=True, text=False, input=None, stdin=None, stdout=None,
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp