diff --git a/src/test_modules/server/ogAdmClient/__init__.py b/src/test_modules/server/ogAdmClient/__init__.py index 9149f36..c91f73b 100644 --- a/src/test_modules/server/ogAdmClient/__init__.py +++ b/src/test_modules/server/ogAdmClient/__init__.py @@ -281,8 +281,8 @@ with open (subprocs_log, 'ab') as fd: ## TODO improve this logging def ejecutaArchivo(self,fn): logger.debug ('fn ({})'.format (fn)) - ## TODO hay que entender este codigo (ogAdmClient.c:2111) para poder traducirlo a python - ## en una funcion "ejecutaArchivo" esperaba que se ejecutara un archivo, pero solo hay una llamada a gestionaTrama() que no sé dónde termina + ## TODO need to understand this code (ogAdmClient.c:2111) before translating it to python + ## in a function called "ejecutaArchivo" I'd expect a file to be run, however there's only a call to gestionaTrama() that I don't know where it leads to #char* buffer,*lineas[MAXIMAS_LINEAS]; #int i,numlin; #char modulo[] = "ejecutaArchivo()"; @@ -302,14 +302,14 @@ with open (subprocs_log, 'ab') as fd: ## TODO improve this logging # } #liberaMemoria(buffer); - ## voy a probar algo, asumiendo que en el archivo no hay simplemente un bash, sino secuencias de parametros tal que "nfn=Funcion\rparam1=foo\rparam2=bar" + ## let's test something, assuming that in the "file" there's not just some bash, but a sequence of parameters such as "nfn=Function\rparam1=foo\rparam2=bar" buffer = subprocess.run (['cat', fn], capture_output=True).stdout.strip().decode ('utf-8') - logger.debug ('buffer ({})'.format (buffer.replace('\r', '\\r'))) ## sustituimos \r para que el log tenga sentido + logger.debug ('buffer ({})'.format (buffer.replace('\r', '\\r'))) ## change \r so as not to mess with the log if buffer: for l in buffer.split('@'): if not len(l): continue logger.debug ('line ({})'.format (l)) - ## en este punto, una opción sería pegar un curl a localhost, pero también podemos parsear los parámetros y llamar localmente a la función que sea: + ## at this point, an option would be fire up a curl to localhost, but we can also parse the params and locally call the desired function: post_params = {} for param in l.split("\r"): k, v = param.split('=') @@ -321,7 +321,7 @@ with open (subprocs_log, 'ab') as fd: ## TODO improve this logging logger.error ('Ha ocurrido algún problema al procesar la trama recibida') break func = getattr (self, 'process_' + func_name) - ## func ya es una referencia a self.func, de modo que ahora no hay que hacer self.func(...) ni tampoco func(self, ...) + ## func is already a ref to self.func, so we don't have to call self.func(...) or func(self, ...) logger.debug ('calling function "{}" with post_params "{}"'.format (func_name, post_params)) output = func ([], {}, post_params, None) @@ -396,7 +396,7 @@ with open (subprocs_log, 'ab') as fd: ## TODO improve this logging def comandosPendientes(self): while (True): - res = self.enviaMensajeServidor ('ComandosPendientes') ## recibe un solo comando + res = self.enviaMensajeServidor ('ComandosPendientes') ## receives just one command if (type(res) is not dict): logger.error ('Ha ocurrido algún problema al enviar una petición de comandos o tareas pendientes al Servidor de Administración') logger.error ('Ha ocurrido algún problema al recibir una petición de comandos o tareas pendientes desde el Servidor de Administración') @@ -406,12 +406,12 @@ with open (subprocs_log, 'ab') as fd: ## TODO improve this logging if ('NoComandosPtes' == res['nfn']): break - ## TODO gestionar los demás casos... igual toca hacer algo parecido a ejecutaArchivo + ## TODO manage the rest of cases... we might have to do something similar to ejecutaArchivo #if(!gestionaTrama(ptrTrama)){ // Análisis de la trama # logger.error ('Ha ocurrido algún problema al procesar la trama recibida') # return False #} - ## de momento le pongo un return False para evitar un posible bucle infinito + ## ATM let's just return false to avoid a possible infinite loop return False return True @@ -423,7 +423,7 @@ with open (subprocs_log, 'ab') as fd: ## TODO improve this logging #p = subprocess.Popen (['/opt/opengnsys/bin/browser', '-qws', url]) p = subprocess.Popen (['/usr/bin/xeyes']) try: - p.wait (2) ## si el proceso se muere antes de 2 segundos... + p.wait (2) ## if the process dies before 2 seconds... logger.error ('Error al ejecutar la llamada a la interface de administración') logger.error ('Error en la creación del proceso hijo') logger.error ('return code "{}"'.format (p.returncode)) @@ -446,8 +446,8 @@ with open (subprocs_log, 'ab') as fd: ## TODO improve this logging logger.info ('Disponibilidad de comandos activada') ## Disponibilidad de cliente activada - ## y hacemos return true y el agente es quien espera peticiones - ## TODO el tema es, ogAdmClient hace comandosPendientes() cada vez, ¿cómo lo metemos aquí? + ## we now return true and the outer agent code gets to wait for requests from outside + ## TODO thing is, ogAdmClient always calls comandosPendientes() after every received request. How do we do that here? # #ptrTrama=recibeMensaje(&socket_c); #if(!ptrTrama){