import paramiko
from scp import SCPClient
import os
import pexpect

# def createSSHClient(server, port, user, password):
#     client = paramiko.SSHClient()
#     client.load_system_host_keys()
#     client.set_missing_host_key_policy(paramiko.AutoAddPolicy)
#     client.connect(server, port, user, password)

#     return client

# ssh = createSSHClient("10.1.29.28", 31931, "root", "whitekirin")

# # os.mkdir("Original_ResNet101V2_with_NPC_Augmentation_Image")
# # with open("Original_ResNet101V2_with_NPC_Augmentation_Image_train3.txt", "w") as file:
# #     pass

# with SCPClient(ssh.get_transport()) as scp:
#     scp.get("/mnt/c/張晉嘉/stomach_cancer/Original_ResNet101V2_with_NPC_Augmentation_Image_train3.txt", "/raid/whitekirin/stomach_cancer/Model_result/save_the_train_result(2024-10-05)/Original_ResNet101V2_with_NPC_Augmentation_Image_train3.txt")

def upload(port, filename, user, ip, dst_path):
    cmdline = "scp %s -r %s %s@%s:%s" % (port, filename, user, ip, dst_path)

    try:
        child = pexpect.spawn(cmdline)
        child.expect("whitekirin109316118")
        child.sendline()
        child.expect(pexpect.EOF)
        print("file upload Finish")
    except Exception as e:
        print("upload faild: ", e)

upload(2222, "/raid/whitekirin/stomach_cancer/Model_result/save_the_train_result(2024-10-05)", "whitekirin", "203.64.84.39", "/mnt/c/張晉嘉/stomach_cancer")