Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 5eede4e

Browse files
committed
fix: fixed client_tester STOR
1 parent 8b4fab3 commit 5eede4e

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

Project/Client/Client_test.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def execute_command(self, command, args=None):
6060
if command in ["LIST", "STOR", "RETR", "STOU", "APPE"]:
6161
return self.handle_data_connection(command, args)
6262
else:
63-
self.send_command(command, args) # Pasar args a send_command
63+
self.send_command(command, args[0]) # Pasar args a send_command
6464
return self.receive_response()
6565

6666
# Ejecuta los comandos que requieren establecer conexion de datos
@@ -130,9 +130,10 @@ def list_file(self, command, args=None):
130130
return self.receive_response()
131131

132132
# Comando para recibir un archivo
133-
def retrieve_file(self, command, filename):
133+
def retrieve_file(self, command, args):
134134
Utils.validate_args(command, filename)
135135

136+
filename = args[0]
136137
# Enviar comando y recibir respuesta
137138
self.send_command(f"{command} {filename}")
138139
response = self.receive_response()
@@ -151,22 +152,23 @@ def retrieve_file(self, command, filename):
151152
return end_response
152153

153154
# Comando para guardar un archivo
154-
def store_file(self, command, filename):
155+
def store_file(self, command, args):
155156
# Maneja los comandos STOR, STOU Y APPEND
156157
Utils.validate_args(command, filename)
157158

158-
# Agregar la carpeta fuente desde donde se enviara el archivo
159-
path = os.path.join(".local" , filename)
160-
161-
# Chequear si el archivo existe localmente
162-
if not os.path.exists(path):
163-
return f"Error: File '{filename}' does not exist"
159+
filename = args[1]
160+
path = args[0]
164161

165162
if command == "STOU":
166163
filename = f"{int(time.time())}_{filename}" # le agrega timestamp para hacer el nombre unico
167164

168165
# Enviar comando
169166
self.send_command(f"{command} {filename}")
167+
stor_response = self.receive_response()
168+
print(stor_response)
169+
170+
if 150 in stor_response:
171+
print("Sending file...")
170172

171173
# Enviar archivo
172174
with open(path, 'rb') as f:
@@ -193,7 +195,7 @@ def start_client(argvs):
193195
ftp_client = Client_test(server, port, username, password )
194196
ftp_client.connect()
195197
ftp_client.auth()
196-
response = ftp_client.execute_command(command, argument1) # esto hay que modificarlo para ajustarse a la entrada de los tests
198+
response = ftp_client.execute_command(command, [argument1, argument2]) # esto hay que modificarlo para ajustarse a la entrada de los tests
197199
print(response)
198200

199201
if __name__ == "__main__":

0 commit comments

Comments
 (0)