class AppDemonio(object): """clase que inicia el demonio de la aplicacion""" def __init__(self,config_file): """se define unos path estándar en linux.""" self._config_file = config_file self._configuracion = Config(self._config_file) self.stdin_path = self._configuracion.show_value_item("paths","null") self.stdout_path = self._configuracion.show_value_item("paths","stdout") self.stderr_path = self._configuracion.show_value_item("paths","stderr") #Se define la ruta del archivo pid del demonio. self.pidfile_path = self._configuracion.show_value_item("paths","pidfile") self.pidfile_timeout = int(self._configuracion.show_value_item("time","timeout")) self.logfile = self._configuracion.show_value_item("paths","logfile") @property def config_file(self): """getter de config_file""" return self._config_file @config_file.setter def config_file(self,config_file): """Setter de config_file""" self._config_file = config_file self._configuracion = Config(self._config_file) self._stdin_path = self._configuracion.show_value_item("paths","null") self._stdout_path = self._configuracion.show_value_item("paths","stdout") self._stderr_path = self._configuracion.show_value_item("paths","stderr") #Se define la ruta del archivo pid del demonio. self._pidfile_path = self._configuracion.show_value_item("paths","pidfile") self._pidfile_timeout = int(self._configuracion.show_value_item("time","timeout")) self._logfile = self._configuracion.show_value_item("paths","logfile") def __getattr__(self): """Si se intenta acceder a un atributo inexistente se devuelve None""" return None def run(self): """Ejecucion del demonio""" cell = Cell() server = SOAPServer(("localhost",8580)) server.registerFunction(cell.detectar_dispositivos) server.registerFunction(cell.listar_forwarding) server.registerFunction(cell.remover_forwarding) server.registerFunction(cell.agregar_forwarding) server.registerFunction(cell.detener_servicio) server.registerFunction(cell.iniciar_servicio) server.registerFunction(cell.port) while True: try: cell.config_file = configfile server.serve_forever() logger.info("deviceCelldaemond started") except KeyboardInterrupt: logger.info("deviceCelldaemond ended") exit() time.sleep(self._pidfile_timeout)
def config_file(self, config_file): """Setter de config_file""" self._config_file = config_file self._configuracion = Config(self._config_file) self._stdin_path = self._configuracion.show_value_item("paths", "null") self._stdout_path = self._configuracion.show_value_item( "paths", "stdout") self._stderr_path = self._configuracion.show_value_item( "paths", "stderr") #Se define la ruta del archivo pid del demonio. self._pidfile_path = self._configuracion.show_value_item( "paths", "pidfile") self._pidfile_timeout = int( self._configuracion.show_value_item("time", "timeout")) self._logfile = self._configuracion.show_value_item("paths", "logfile")
def __init__(self, config_file): """se define unos path estándar en linux.""" self._config_file = config_file self._configuracion = Config(self._config_file) self.stdin_path = self._configuracion.show_value_item("paths", "null") self.stdout_path = self._configuracion.show_value_item( "paths", "stdout") self.stderr_path = self._configuracion.show_value_item( "paths", "stderr") #Se define la ruta del archivo pid del demonio. self.pidfile_path = self._configuracion.show_value_item( "paths", "pidfile") self.pidfile_timeout = int( self._configuracion.show_value_item("time", "timeout")) self.logfile = self._configuracion.show_value_item("paths", "logfile")
def config_file(self,config_file): """Setter de config_file""" self._config_file = config_file self._configuracion = Config(self._config_file) self._stdin_path = self._configuracion.show_value_item("paths","null") self._stdout_path = self._configuracion.show_value_item("paths","stdout") self._stderr_path = self._configuracion.show_value_item("paths","stderr") #Se define la ruta del archivo pid del demonio. self._pidfile_path = self._configuracion.show_value_item("paths","pidfile") self._pidfile_timeout = int(self._configuracion.show_value_item("time","timeout")) self._logfile = self._configuracion.show_value_item("paths","logfile")
def __init__(self,config_file): """se define unos path estándar en linux.""" self._config_file = config_file self._configuracion = Config(self._config_file) self.stdin_path = self._configuracion.show_value_item("paths","null") self.stdout_path = self._configuracion.show_value_item("paths","stdout") self.stderr_path = self._configuracion.show_value_item("paths","stderr") #Se define la ruta del archivo pid del demonio. self.pidfile_path = self._configuracion.show_value_item("paths","pidfile") self.pidfile_timeout = int(self._configuracion.show_value_item("time","timeout")) self.logfile = self._configuracion.show_value_item("paths","logfile")
class AppDemonio(object): """clase que inicia el demonio de la aplicacion""" def __init__(self, config_file): """se define unos path estándar en linux.""" self._config_file = config_file self._configuracion = Config(self._config_file) self.stdin_path = self._configuracion.show_value_item("paths", "null") self.stdout_path = self._configuracion.show_value_item( "paths", "stdout") self.stderr_path = self._configuracion.show_value_item( "paths", "stderr") #Se define la ruta del archivo pid del demonio. self.pidfile_path = self._configuracion.show_value_item( "paths", "pidfile") self.pidfile_timeout = int( self._configuracion.show_value_item("time", "timeout")) self.logfile = self._configuracion.show_value_item("paths", "logfile") @property def config_file(self): """getter de config_file""" return self._config_file @config_file.setter def config_file(self, config_file): """Setter de config_file""" self._config_file = config_file self._configuracion = Config(self._config_file) self._stdin_path = self._configuracion.show_value_item("paths", "null") self._stdout_path = self._configuracion.show_value_item( "paths", "stdout") self._stderr_path = self._configuracion.show_value_item( "paths", "stderr") #Se define la ruta del archivo pid del demonio. self._pidfile_path = self._configuracion.show_value_item( "paths", "pidfile") self._pidfile_timeout = int( self._configuracion.show_value_item("time", "timeout")) self._logfile = self._configuracion.show_value_item("paths", "logfile") def __getattr__(self): """Si se intenta acceder a un atributo inexistente se devuelve None""" return None def run(self): """Ejecucion del demonio""" cell = Cell() server = SOAPServer(("localhost", 8580)) server.registerFunction(cell.detectar_dispositivos) server.registerFunction(cell.listar_forwarding) server.registerFunction(cell.remover_forwarding) server.registerFunction(cell.agregar_forwarding) server.registerFunction(cell.detener_servicio) server.registerFunction(cell.iniciar_servicio) server.registerFunction(cell.port) while True: try: cell.config_file = configfile server.serve_forever() logger.info("deviceCelldaemond started") except KeyboardInterrupt: logger.info("deviceCelldaemond ended") exit() time.sleep(self._pidfile_timeout)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from pywrapper_config import Config config = Config("./conf-examples/tests.conf") print(config.show_sections()) print(config.show_sectionsJSON()) print(config.show_item_section('server')) print(config.show_item_sectionJSON('server')) print(config.show_value_item('server', 'ip')) print(config.show_value_itemJSON('server', 'ip'))