Skip to content

Commit

Permalink
Merge pull request #118 from olehermanse/master
Browse files Browse the repository at this point in the history
cf-remote: Made nt-discovery parts quiet by default
  • Loading branch information
olehermanse authored Jan 29, 2025
2 parents af73dc9 + b4fae84 commit e755d24
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cf_remote/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def get_info(host, *, users=None, connection=None):
else:
data["os"] = "unix"

scp("nt-discovery.sh", host, connection)
scp("nt-discovery.sh", host, connection, hide=True)
discovery = parse_envfile(ssh_sudo(connection, "bash nt-discovery.sh"))

if discovery is None:
Expand Down
17 changes: 9 additions & 8 deletions cf_remote/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ def run(self, command, hide=False):
results = aramid.execute([ahost], command, echo=(not hide))
return results[ahost][0]

def put(self, src):
def put(self, src, hide=False):
dst = os.path.basename(src)
ahost = aramid.Host(self.ssh_host, self.ssh_user)
results = aramid.put([ahost], src, dst)
results = aramid.put([ahost], src, dst, echo=(not hide))
return results[ahost][0].retcode

def __enter__(self, *args, **kwargs):
Expand Down Expand Up @@ -159,19 +159,20 @@ def connect_wrapper(host, *args, **kwargs):
return connect_wrapper


def scp(file, remote, connection=None, rename=None):
def scp(file, remote, connection=None, rename=None, hide=False):
if not connection:
with connect(remote) as connection:
scp(file, remote, connection, rename)
scp(file, remote, connection, rename, hide=hide)
else:
print("Copying: '%s' to '%s'" % (file, remote))
connection.put(file)
print_function = log.debug if hide else print
print_function("Copying: '%s' to '%s'" % (file, remote))
connection.put(file, hide=hide)
if rename:
file = os.path.basename(file)
if file == rename:
return 0
print("Renaming '%s' -> '%s' on '%s'" % (file, rename, remote))
ssh_cmd(connection, "mv %s %s" % (file, rename))
print_function("Renaming '%s' -> '%s' on '%s'" % (file, rename, remote))
ssh_cmd(connection, "mv %s %s" % (file, rename), hide=hide)
return 0


Expand Down

0 comments on commit e755d24

Please sign in to comment.