@@ -60,7 +60,7 @@ def execute_command(self, command, args=None):
60
60
if command in ["LIST" , "STOR" , "RETR" , "STOU" , "APPE" ]:
61
61
return self .handle_data_connection (command , args )
62
62
else :
63
- self .send_command (command , args ) # Pasar args a send_command
63
+ self .send_command (command , args [ 0 ] ) # Pasar args a send_command
64
64
return self .receive_response ()
65
65
66
66
# Ejecuta los comandos que requieren establecer conexion de datos
@@ -130,9 +130,10 @@ def list_file(self, command, args=None):
130
130
return self .receive_response ()
131
131
132
132
# Comando para recibir un archivo
133
- def retrieve_file (self , command , filename ):
133
+ def retrieve_file (self , command , args ):
134
134
Utils .validate_args (command , filename )
135
135
136
+ filename = args [0 ]
136
137
# Enviar comando y recibir respuesta
137
138
self .send_command (f"{ command } { filename } " )
138
139
response = self .receive_response ()
@@ -151,22 +152,23 @@ def retrieve_file(self, command, filename):
151
152
return end_response
152
153
153
154
# Comando para guardar un archivo
154
- def store_file (self , command , filename ):
155
+ def store_file (self , command , args ):
155
156
# Maneja los comandos STOR, STOU Y APPEND
156
157
Utils .validate_args (command , filename )
157
158
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 ]
164
161
165
162
if command == "STOU" :
166
163
filename = f"{ int (time .time ())} _{ filename } " # le agrega timestamp para hacer el nombre unico
167
164
168
165
# Enviar comando
169
166
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..." )
170
172
171
173
# Enviar archivo
172
174
with open (path , 'rb' ) as f :
@@ -193,7 +195,7 @@ def start_client(argvs):
193
195
ftp_client = Client_test (server , port , username , password )
194
196
ftp_client .connect ()
195
197
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
197
199
print (response )
198
200
199
201
if __name__ == "__main__" :
0 commit comments