diff --git a/src/opengnsys/modules/server/ogAdmClient/__init__.py b/src/opengnsys/modules/server/ogAdmClient/__init__.py index 04352ad..fadb761 100644 --- a/src/opengnsys/modules/server/ogAdmClient/__init__.py +++ b/src/opengnsys/modules/server/ogAdmClient/__init__.py @@ -35,7 +35,6 @@ import base64 import os -#import random import shutil import string import threading @@ -77,8 +76,6 @@ class ogAdmClientWorker (ServerWorker): name = 'ogAdmClient' # Module name #interface = None # Bound interface for OpenGnsys (el otro modulo lo usa para obtener .ip y .mac REST = None # REST object - #random = None # Random string for secure connections - #length = 32 # Random string length tbErroresScripts = [ "Se han generado errores desconocidos. No se puede continuar la ejecución de este módulo", ## 0 @@ -174,34 +171,6 @@ class ogAdmClientWorker (ServerWorker): def onLogout (self, user): logger.warning ('in onLogout, should not happen') - #def process_ogclient (self, path, get_params, post_params, server): - # """ - # This method can be overridden to provide your own message processor, or better you can - # implement a method that is called exactly as "process_" + path[0] (module name has been removed from path - # array) and this default processMessage will invoke it - # * Example: - # Imagine this invocation url (no matter if GET or POST): http://example.com:9999/Sample/mazinger/Z - # The HTTP Server will remove "Sample" from path, parse arguments and invoke this method as this: - # module.processMessage (["mazinger","Z"], get_params, post_params) - - # This method will process "mazinger", and look for a "self" method that is called "process_mazinger", - # and invoke it this way: - # return self.process_mazinger (["Z"], get_params, post_params) - - # In the case path is empty (that is, the path is composed only by the module name, like in - # "http://example.com/Sample", the "process" method will be invoked directly - - # The methods must return data that can be serialized to json (i.e. Objects are not serializable to json, - # basic type are) - # """ - # if not path: - # return "ok" - # try: - # operation = getattr (self, 'ogclient_' + path[0]) - # except Exception: - # raise Exception ('Message processor for "{}" not found'.format (path[0])) - # return operation (path[1:], get_params, post_params) - @check_secret def process_status (self, path, get_params, post_params, server): return {'ogAdmClient': 'in process_status'} ## XXX @@ -243,10 +212,6 @@ class ogAdmClientWorker (ServerWorker): threading.Thread (target=pwoff).start() return {'op': 'launched'} - #@check_secret - #def process_logoff (self, path, get_params, post_params, server): - # logger.warning ('in process_logoff, should not happen') - ## curl --insecure -X POST --data '{"nfn": "popup", "title": "my title", "message": "my message"}' https://192.168.1.249:8000/ogAdmClient/popup @check_secret def process_popup (self, path, get_params, post_params, server): @@ -263,8 +228,6 @@ class ogAdmClientWorker (ServerWorker): - #def process_client_popup (self, params): - # logger.warning ('in process_client_popup') ## process_* are invoked from opengnsys/httpserver.py:99 "data = module.processServerMessage (path, get_params, post_params, self)" (via opengnsys/workers/server_worker.py) @@ -332,28 +295,7 @@ class ogAdmClientWorker (ServerWorker): def ejecutaArchivo (self,fn): logger.debug ('fn ({})'.format (fn)) - ## 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()"; - - #buffer = leeArchivo(filecmd); - #if (buffer): - # numlin = splitCadena(lineas, buffer, '@'); - # initParametros(ptrTrama,0); - # for (i = 0; i < numlin; i++) { - # if(strlen(lineas[i])>0){ - # strcpy(ptrTrama->parametros,lineas[i]); - # if(!gestionaTrama(ptrTrama)){ // Análisis de la trama - # errorLog(modulo,39,FALSE); - # //return(FALSE); - # } - # } - # } - #liberaMemoria(buffer); - - ## 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" + ## 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'))) ## change \r so as not to mess with the log if buffer: @@ -411,14 +353,6 @@ class ogAdmClientWorker (ServerWorker): def cuestionCache (self): return True ## ogAdmClient.c:425 - #>>>>>>>>>>>>>>>>>>>>>>>>>> - #try: - # self.interfaceAdmin ('procesaCache', [self.cache]); - #except Exception as e: - # logger.error ('Ha habido algún problerma al procesar la caché') - # return False - # - #return True def autoexecCliente (self): res = self.enviaMensajeServidor ('AutoexecCliente', { 'exe': self.idproautoexec }) @@ -535,8 +469,6 @@ class ogAdmClientWorker (ServerWorker): self.idcentro = None ## Identificador del centro self.idaula = None ## Identificador del aula - # Generate random secret to send on activation - #self.random = ''.join (random.choice (string.ascii_lowercase + string.digits) for _ in range (self.length)) # Ensure cfg has required configuration variables or an exception will be thrown try: url = self.service.config.get ('ogAdmClient', 'remote') @@ -657,8 +589,6 @@ class ogAdmClientWorker (ServerWorker): logger.debug ('in process_CrearImagen, path "{}" get_params "{}" post_params "{}" server "{}"'.format (path, get_params, post_params, server)) logger.debug ('type(post_params) "{}"'.format (type (post_params))) - logger.debug ('Ejecución de comando'); - for k in ['dsk', 'par', 'cpt', 'idi', 'nci', 'ipr', 'nfn', 'ids']: if k not in post_params: logger.error (f'required parameter ({k}) not in POST params')