Skip to content

Commit

Permalink
try this ssh
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Feb 5, 2025
1 parent a787c99 commit aff600d
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions pioreactor/utils/networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,27 @@

def ssh(address: str, command: str):
try:
r = subprocess.run(["ssh", "-o", "ConnectTimeout=10", address, f'"{command}"'], check=True)
assert r.returncode == 0
subprocess.run(
["ssh", "-o", "ConnectTimeout=5", address, command],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
)
except subprocess.CalledProcessError as e:
raise SSHError from e
raise SSHError(f"SSH command failed: {e.stderr}") from e


def rsync(*args: str) -> None:
try:
r = subprocess.run(("rsync",) + args, check=True)
assert r.returncode == 0
subprocess.run(
("rsync",) + args,
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
except subprocess.CalledProcessError as e:
raise RsyncError from e
raise RsyncError(f"rysnc command failed: {e.stderr}") from e


def cp_file_across_cluster(unit: str, localpath: str, remotepath: str, timeout: int = 5) -> None:
Expand Down

0 comments on commit aff600d

Please sign in to comment.