I'm using paramiko to script out downloading a large file on a virtual machine. When I pass in my wget command, it'll correctly execute it, but instead of moving on to execute the next lines of python, it'll end execution and dump the stdout of exec_command into my terminal. I found some code online to try to continuously print stdout lines, but that doesn't output anything either, I just get the output dump in my terminal.
Relevant parts of my code. Is there anything I should change?
def download_model(connection: SSHClient, url: str, job_id: str):
name = job_id + ".safetensors"
stdin, stdout, stderr = connection.exec_command(
"cd /workspace;" +
"wget -O " + name + " \"" + url + "\"")
for line in iter(lambda: stdout.readline(2048), ""):
print(line)
err=stderr.readline()
if len(err) != 0:
raise RuntimeError(err)
return True
def check_model(url: str, job_id: str):
name = job_id + ".safetensors"
stdin, stdout, stderr = connection.exec_command(
"cd /workspace;" +
"test -e" + url + " && echo file exists || echo file not found")
output = stdout.readlines()
return output
if __name__ == "__main__":
connection = key_based_connect(8695)
print(connection.get_transport().is_active())
print("downloading model " + JOB_ID)
output = download_model(connection, URL, JOB_ID)
"""Execution stops here"""
if output:
print("checking model")
new_output = check_model(MODEL_URL, JOB_ID)
print(new_output[0])
connection.close()
print("connection closed")