def validate(self, button): """ Triggered when the user presses the "OK" button """ chosen_port = int(self.port_edit_box.value()) actual_port = int(cr_config.get_config_value('Webserver', 'port')) if self.items[0].state: if chosen_port != actual_port and check_port('127.0.0.1', chosen_port) is True: error_dialog = cr.cli.DialogCli('This port is already used by another application. Please choose a ' 'free port.') error_dialog.display() return cr_config.set_config_value('Webserver', 'enable', 'True') cr_config.set_config_value('Webserver', 'port', str(self.port_edit_box.value())) else: cr_config.set_config_value('Webserver', 'enable', 'False') cr.cli.quit()
def validate(self, button): """ Triggered when the user presses the "OK" button """ chosen_port = int(self.port_edit_box.value()) actual_port = int(cr_config.get_config_value('Webserver', 'port')) if self.items[0].state: if chosen_port != actual_port and check_port( '127.0.0.1', chosen_port) is True: error_dialog = cr.cli.DialogCli( 'This port is already used by another application. Please choose a ' 'free port.') error_dialog.display() return cr_config.set_config_value('Webserver', 'enable', 'True') cr_config.set_config_value('Webserver', 'port', str(self.port_edit_box.value())) else: cr_config.set_config_value('Webserver', 'enable', 'False') cr.cli.quit()
def run(self): """ Constructor. """ is_error = False # If True, there are one or more errors when CentralReport is trying to start log.log_info("------------------------------------------------") log.log_info("CentralReport is starting...") log.log_info("Current user: "******"Debug", "log_level") except: log_level = "INFO" log.change_log_level(log_level) # Starting the check thread... if host.get_current_host().os != host.OS_UNKNOWN: log.log_info("%s detected. Starting ThreadChecks..." % host.get_current_host().os) CentralReport.checks_thread = threads.Checks() # Launching checks thread else: is_error = True log.log_critical("Sorry, but your OS is not supported yet...") # Starting the internal webserver... if not is_error and text.convert_text_to_bool(Config.get_config_value("Webserver", "enable")): local_web_port = int(Config.get_config_value("Webserver", "port")) if not utils_web.check_port("127.0.0.1", local_web_port): log.log_info("Starting the webserver...") # Importing the module here improve the memory usage import cr.web CentralReport.webserver_thread = cr.web.server.WebServer() else: log.log_error("Error launching the webserver: port %s is already in use on this host!" % local_web_port) else: log.log_info("Webserver is disabled by configuration file!") if not is_error: log.log_info("CentralReport started!") while CentralReport.is_running: if not Config.CR_CONFIG_ENABLE_DEBUG_MODE: # If .pid file is not found, we must stop CR (only in production environment) try: pf = file(self.pidfile, "r") pf.close() except IOError: log.log_error("Pid file is not found. CentralReport must stop itself.") CentralReport.is_running = False self.stop() time.sleep(1) else: log.log_error("Error launching CentralReport!")
def run(self): """ Constructor. """ is_error = False # If True, there are one or more errors when CentralReport is trying to start log.log_info('------------------------------------------------') log.log_info('CentralReport is starting...') log.log_info('Current user: '******'Debug', 'log_level') except: log_level = 'INFO' log.change_log_level(log_level) # Starting the check thread... if host.get_current_host().os != host.OS_UNKNOWN: log.log_info('%s detected. Starting ThreadChecks...' % host.get_current_host().os) CentralReport.checks_thread = threads.Checks( ) # Launching checks thread else: is_error = True log.log_critical('Sorry, but your OS is not supported yet...') # Starting the internal webserver... if not is_error and text.convert_text_to_bool( Config.get_config_value('Webserver', 'enable')): local_web_port = int(Config.get_config_value('Webserver', 'port')) if not utils_web.check_port('127.0.0.1', local_web_port): log.log_info('Starting the webserver...') # Importing the module here improve the memory usage import cr.web CentralReport.webserver_thread = cr.web.server.WebServer() else: log.log_error( 'Error launching the webserver: port %s is already in use on this host!' % local_web_port) else: log.log_info('Webserver is disabled by configuration file!') if not is_error: log.log_info('CentralReport started!') while CentralReport.is_running: if not Config.CR_CONFIG_ENABLE_DEBUG_MODE: # If .pid file is not found, we must stop CR (only in production environment) try: pf = file(self.pidfile, 'r') pf.close() except IOError: log.log_error( 'Pid file is not found. CentralReport must stop itself.' ) CentralReport.is_running = False self.stop() time.sleep(1) else: log.log_error('Error launching CentralReport!')