def main(): ''' Call functions in the correct order based on CLI params. It's important that we import and call stuff after proccessing all of the tornado.options, if you try to import something that uses tornado.options before we parse it you'll end up with lots of undefined variables! ''' parse_config_options() if options.save: save_config() if options.setup is not None: setup() elif options.start: start()
def update_configuration(config): """ Update Configuration options based on XML data """ if config is None: return else: """ Backup configuration """ copyfile(options.config, options.config + ".bak") images = ["ctf_logo", "story_character", "scoreboard_right_image"] for config_elem in config: try: if options[config_elem.tag] is not None: if config_elem.tag in images: value = save_config_image(get_child_text(config, config_elem.tag)) else: value = get_child_text(config, config_elem.tag) if isinstance(value, type(options[config_elem.tag])): logging.info("Configuration (%s): %s" % (config_elem.tag, value)) options[config_elem.tag] = value except BaseException as e: logging.exception("Faild to update configuration (%s)" % e) save_config()
def update_configuration(config): """ Update Configuration options based on XML data """ if config is None: return else: """ Backup configuration """ copyfile(options.config, options.config + ".bak") images = ["ctf_logo", "story_character", "scoreboard_right_image"] for config_elem in config: try: if options[config_elem.tag] is not None: if config_elem.tag in images: value = save_config_image( get_child_text(config, config_elem.tag)) elif isinstance(options[config_elem.tag], list): lines = [] for line in get_child_by_tag(config, config_elem.tag): lines.append(line.text) value = lines else: value = get_child_text(config, config_elem.tag) value = set_type(value, options[config_elem.tag]) if isinstance(value, type(options[config_elem.tag])): logging.info("Configuration (%s): %s" % (config_elem.tag, value)) options[config_elem.tag] = value else: logging.error( "Confirguation (%s): unable to convert type %s to %s for %s" % ( config_elem.tag, type(value), type(options[config_elem.tag]), value, )) except BaseException as e: logging.exception("Faild to update configuration (%s)" % e) save_config()
def on_finish(self): save_config()
os._exit(1) check_cwd() if options.version: version() elif options.setup.startswith("docker"): if not os.path.isfile(options.sql_database + ".db"): logging.info("Running Docker Setup") options.admin_ips = [ ] # Remove admin ips due to docker 127.0.0.1 mapping options.memcached = "memcached" options.x_headers = True options_parse_environment( ) # Pick up env vars before saving config file. save_config() setup() else: options.parse_config_file(options.config) options.start = True elif options.save or not os.path.isfile(options.config): save_config() print( INFO + bold + "If necessary, update the db username and password in the cfg and set any advanced configuration options." ) if not options.setup: os._exit(1) else: logging.debug("Parsing config file `%s`" % (os.path.abspath(options.config), ))
help="root the box configuration file") if __name__ == '__main__': # We need this to pull the --config option options.parse_command_line() check_cwd() if os.path.isfile(options.config): logging.debug("Parsing config file `%s`" % ( os.path.abspath(options.config), )) options.parse_config_file(options.config) # Make sure that cli args always have president over the file options.parse_command_line() if options.save: save_config() if options.setup.lower()[:3] in ['pro', 'dev']: setup() elif options.start: start() elif options.restart: restart() elif options.recovery: recovery() elif options.version: version()