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):
logger.warn ('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)
#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)
# 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
# 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)
# 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'}
return {'ogAdmClient': 'in process_status'} ## XXX
@check_secret
def process_reboot (self, path, get_params, post_params, server):
@ -172,10 +172,11 @@ class ogAdmClientWorker(ServerWorker):
threading.Thread (target=pwoff).start()
return {'op': 'launched'}
@check_secret
def process_logoff(self, path, get_params, post_params, server):
logger.warn('in process_logoff, should not happen')
#@check_secret
#def process_logoff (self, path, get_params, post_params, server):
# 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
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))
@ -226,7 +227,7 @@ class ogAdmClientWorker(ServerWorker):
def LeeConfiguracion(self):
parametroscfg = self.interfaceAdmin ('getConfiguration') ## Configuración de los Sistemas Operativos del cliente
logger.debug ('parametroscfg ({})'.format (parametroscfg))
return (parametroscfg)
return parametroscfg
def enviaMensajeServidor (self, path, obj={}):
obj['iph'] = self.IPlocal ## Ip del ordenador
@ -452,7 +453,7 @@ class ogAdmClientWorker(ServerWorker):
raise e
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')
logger.info ('Inicio de sesion')
@ -462,16 +463,16 @@ class ogAdmClientWorker(ServerWorker):
logger.info ('Cliente iniciado')
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')
if (self.idproautoexec > 0):
if self.idproautoexec > 0:
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')
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')
logger.info ('Acciones pendientes procesadas')
@ -482,6 +483,7 @@ class ogAdmClientWorker(ServerWorker):
def process_NoComandosPtes(self, path, get_params, post_params, server):
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):
logger.warn ('in process_Actualizar')