Spaces:
Running
on
Zero
Running
on
Zero
update upload
Browse files- serve/upload.py +10 -1
serve/upload.py
CHANGED
|
@@ -10,6 +10,7 @@ from .constants import SSH_SERVER, SSH_PORT, SSH_USER, SSH_PASSWORD, SSH_LOG, SS
|
|
| 10 |
|
| 11 |
ssh_client = None
|
| 12 |
sftp_client = None
|
|
|
|
| 13 |
|
| 14 |
def create_ssh_client(server, port, user, password):
|
| 15 |
global ssh_client, sftp_client
|
|
@@ -22,6 +23,13 @@ def create_ssh_client(server, port, user, password):
|
|
| 22 |
transport.set_keepalive(60)
|
| 23 |
|
| 24 |
sftp_client = ssh_client.open_sftp()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
def is_connected():
|
| 26 |
global ssh_client, sftp_client
|
| 27 |
if ssh_client is None or sftp_client is None:
|
|
@@ -95,6 +103,7 @@ def upload_images(i, image_list, output_file_list, sftp_client):
|
|
| 95 |
|
| 96 |
def upload_ssh_all(states, output_dir, data, data_path):
|
| 97 |
global sftp_client
|
|
|
|
| 98 |
if not is_connected():
|
| 99 |
create_ssh_client(SSH_SERVER, SSH_PORT, SSH_USER, SSH_PASSWORD)
|
| 100 |
output_file_list = []
|
|
@@ -106,7 +115,7 @@ def upload_ssh_all(states, output_dir, data, data_path):
|
|
| 106 |
|
| 107 |
|
| 108 |
with concurrent.futures.ThreadPoolExecutor() as executor:
|
| 109 |
-
futures = [executor.submit(upload_images, i, image_list, output_file_list,
|
| 110 |
|
| 111 |
# for i in range(len(output_file_list)):
|
| 112 |
# if isinstance(image_list[i], str):
|
|
|
|
| 10 |
|
| 11 |
ssh_client = None
|
| 12 |
sftp_client = None
|
| 13 |
+
sftp_client_imgs = None
|
| 14 |
|
| 15 |
def create_ssh_client(server, port, user, password):
|
| 16 |
global ssh_client, sftp_client
|
|
|
|
| 23 |
transport.set_keepalive(60)
|
| 24 |
|
| 25 |
sftp_client = ssh_client.open_sftp()
|
| 26 |
+
sftp_client_1 = ssh_client.open_sftp()
|
| 27 |
+
sftp_client_2 = ssh_client.open_sftp()
|
| 28 |
+
sftp_client_3 = ssh_client.open_sftp()
|
| 29 |
+
sftp_client_4 = ssh_client.open_sftp()
|
| 30 |
+
sftp_client_imgs = [sftp_client_1, sftp_client_2, sftp_client_3, sftp_client_4]
|
| 31 |
+
|
| 32 |
+
|
| 33 |
def is_connected():
|
| 34 |
global ssh_client, sftp_client
|
| 35 |
if ssh_client is None or sftp_client is None:
|
|
|
|
| 103 |
|
| 104 |
def upload_ssh_all(states, output_dir, data, data_path):
|
| 105 |
global sftp_client
|
| 106 |
+
global sftp_client_imgs
|
| 107 |
if not is_connected():
|
| 108 |
create_ssh_client(SSH_SERVER, SSH_PORT, SSH_USER, SSH_PASSWORD)
|
| 109 |
output_file_list = []
|
|
|
|
| 115 |
|
| 116 |
|
| 117 |
with concurrent.futures.ThreadPoolExecutor() as executor:
|
| 118 |
+
futures = [executor.submit(upload_images, i, image_list, output_file_list, sftp_client_imgs[i]) for i in range(len(output_file_list))]
|
| 119 |
|
| 120 |
# for i in range(len(output_file_list)):
|
| 121 |
# if isinstance(image_list[i], str):
|