From 795efd199cc0bf49d91f42a0992ae0b8984a4c1e Mon Sep 17 00:00:00 2001 From: las1g21 <las1g21@soton.ac.uk> Date: Fri, 29 Nov 2024 15:35:48 +0000 Subject: [PATCH] Added Sending Files and Connect to Iridis --- .gitignore | 3 +- mona-ssc | 1 + scripts/scene_completion.py | 63 +++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 160000 mona-ssc create mode 100644 scripts/scene_completion.py diff --git a/.gitignore b/.gitignore index 6b5efc0..2fd82f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ scripts/360monodepthexecution/rgb.jpg scripts/shifted_t.png scripts/config.ini -*.pyc \ No newline at end of file +*.pyc +.env \ No newline at end of file diff --git a/mona-ssc b/mona-ssc new file mode 160000 index 0000000..a081661 --- /dev/null +++ b/mona-ssc @@ -0,0 +1 @@ +Subproject commit a0816610da9fa1ed52674240d8343b5643f0e25c diff --git a/scripts/scene_completion.py b/scripts/scene_completion.py new file mode 100644 index 0000000..64f23b7 --- /dev/null +++ b/scripts/scene_completion.py @@ -0,0 +1,63 @@ +import paramiko +from dotenv import load_dotenv +from scp import SCPClient +import os + +load_dotenv() +hostname = os.getenv("HOSTNAME") +username = os.getenv("USERNAME") +password = os.getenv("PASSWORD") + +def send_files(shifted_disparity_path, shifted_t_path): + + command = [ + "scp", + shifted_disparity_path, + f"{username}@{hostname}:{os.getenv("REMOTE_INPUT_PATH")}" + ] + try: + subprocess.run(command, check=True) + + except subprocess.CalledProcessError as e: + print(f"Error during SCP: {e}") + return False + + + command = [ + "scp", + shifted_t_path, + f"{username}@{hostname}:{os.getenv("REMOTE_INPUT_PATH")}" + ] + try: + subprocess.run(command, check=True) + + except subprocess.CalledProcessError as e: + print(f"Error during SCP: {e}") + return False + return True + +def get_completed_scene(shifted_disparity_path, shifted_t_path): + if send_files(shifted_disparity_path, shifted_t_path): + + client = paramiko.SSHClient() + client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + + # Connect to the server + client.connect(hostname, username=username, password=password) + + # Execute commands on the server + stdin, stdout, stderr = client.exec_command("ls -l") + + print("AHAHAHAHAHAHAH\n") + + # Print the output of the command + print(stdout.read()) + + # Close the SSH connection + client.close() + + else: + return False + + + -- GitLab