refs #702 reformat function calls

pull/9/head
Natalia Serrano 2024-09-12 14:57:24 +02:00 committed by Natalia Serrano
parent ffa80a9af2
commit 79dcefc0b4
1 changed files with 151 additions and 149 deletions

View File

@ -103,37 +103,37 @@ class ogAdmClientWorker(ServerWorker):
def onLogout (self, user): def onLogout (self, user):
logger.warn ('in onLogout, should not happen') logger.warn ('in onLogout, should not happen')
def process_ogclient(self, path, get_params, post_params, server): #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 # 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 # 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 # array) and this default processMessage will invoke it
* Example: # * Example:
Imagine this invocation url (no matter if GET or POST): http://example.com:9999/Sample/mazinger/Z # 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: # The HTTP Server will remove "Sample" from path, parse arguments and invoke this method as this:
module.processMessage(["mazinger","Z"], get_params, post_params) # module.processMessage (["mazinger","Z"], get_params, post_params)
This method will process "mazinger", and look for a "self" method that is called "process_mazinger", # This method will process "mazinger", and look for a "self" method that is called "process_mazinger",
and invoke it this way: # and invoke it this way:
return self.process_mazinger(["Z"], get_params, post_params) # 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 # 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 # "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, # The methods must return data that can be serialized to json (i.e. Objects are not serializable to json,
basic type are) # basic type are)
""" # """
if not path: # if not path:
return "ok" # return "ok"
try: # try:
operation = getattr(self, 'ogclient_' + path[0]) # operation = getattr (self, 'ogclient_' + path[0])
except Exception: # except Exception:
raise Exception('Message processor for "{}" not found'.format(path[0])) # raise Exception ('Message processor for "{}" not found'.format (path[0]))
return operation(path[1:], get_params, post_params) # return operation (path[1:], get_params, post_params)
@check_secret @check_secret
def process_status (self, path, get_params, post_params, server): def process_status (self, path, get_params, post_params, server):
return {'ogAdmClient': 'in process_status'} return {'ogAdmClient': 'in process_status'} ## XXX
@check_secret @check_secret
def process_reboot (self, path, get_params, post_params, server): def process_reboot (self, path, get_params, post_params, server):
@ -172,10 +172,11 @@ class ogAdmClientWorker(ServerWorker):
threading.Thread (target=pwoff).start() threading.Thread (target=pwoff).start()
return {'op': 'launched'} return {'op': 'launched'}
@check_secret #@check_secret
def process_logoff(self, path, get_params, post_params, server): #def process_logoff (self, path, get_params, post_params, server):
logger.warn('in process_logoff, should not happen') # logger.warn ('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 @check_secret
def process_popup (self, path, get_params, post_params, server): def process_popup (self, path, get_params, post_params, server):
logger.debug ('in process_popup, path "{}" get_params "{}" post_params "{}" server "{}"'.format (path, get_params, post_params, server)) logger.debug ('in process_popup, path "{}" get_params "{}" post_params "{}" server "{}"'.format (path, get_params, post_params, server))
@ -226,7 +227,7 @@ class ogAdmClientWorker(ServerWorker):
def LeeConfiguracion(self): def LeeConfiguracion(self):
parametroscfg = self.interfaceAdmin ('getConfiguration') ## Configuración de los Sistemas Operativos del cliente parametroscfg = self.interfaceAdmin ('getConfiguration') ## Configuración de los Sistemas Operativos del cliente
logger.debug ('parametroscfg ({})'.format (parametroscfg)) logger.debug ('parametroscfg ({})'.format (parametroscfg))
return (parametroscfg) return parametroscfg
def enviaMensajeServidor (self, path, obj={}): def enviaMensajeServidor (self, path, obj={}):
obj['iph'] = self.IPlocal ## Ip del ordenador obj['iph'] = self.IPlocal ## Ip del ordenador
@ -452,7 +453,7 @@ class ogAdmClientWorker(ServerWorker):
raise e raise e
self.REST = REST (url) self.REST = REST (url)
if (not self.tomaIPlocal()): if not self.tomaIPlocal():
raise Exception ('Se han generado errores. No se puede continuar la ejecución de este módulo') raise Exception ('Se han generado errores. No se puede continuar la ejecución de este módulo')
logger.info ('Inicio de sesion') logger.info ('Inicio de sesion')
@ -462,16 +463,16 @@ class ogAdmClientWorker(ServerWorker):
logger.info ('Cliente iniciado') logger.info ('Cliente iniciado')
logger.info ('Procesando caché') logger.info ('Procesando caché')
if (not self.cuestionCache()): if not self.cuestionCache():
raise Exception ('Se han generado errores. No se puede continuar la ejecución de este módulo') raise Exception ('Se han generado errores. No se puede continuar la ejecución de este módulo')
if (self.idproautoexec > 0): if self.idproautoexec > 0:
logger.info ('Ejecución de archivo Autoexec') logger.info ('Ejecución de archivo Autoexec')
if (not self.autoexecCliente()): if not self.autoexecCliente():
raise Exception ('Se han generado errores. No se puede continuar la ejecución de este módulo') raise Exception ('Se han generado errores. No se puede continuar la ejecución de este módulo')
logger.info ('Procesa comandos pendientes') logger.info ('Procesa comandos pendientes')
if (not self.comandosPendientes()): if not self.comandosPendientes():
raise Exception ('Se han generado errores. No se puede continuar la ejecución de este módulo') raise Exception ('Se han generado errores. No se puede continuar la ejecución de este módulo')
logger.info ('Acciones pendientes procesadas') logger.info ('Acciones pendientes procesadas')
@ -482,6 +483,7 @@ class ogAdmClientWorker(ServerWorker):
def process_NoComandosPtes(self, path, get_params, post_params, server): def process_NoComandosPtes(self, path, get_params, post_params, server):
logger.warn('in process_NoComandosPtes') logger.warn('in process_NoComandosPtes')
## curl --insecure https://192.168.1.249:8000/ogAdmClient/Actualizar
def process_Actualizar (self, path, get_params, post_params, server): def process_Actualizar (self, path, get_params, post_params, server):
logger.warn ('in process_Actualizar') logger.warn ('in process_Actualizar')