def _install(default_config): mcmd.io.io.info("Looks like this is your first time running {}!\n " "Let's take a moment to set things up. It's OK to leave some fields empty, you can always change " "them later.".format(highlight("Molgenis Commander"))) mcmd.io.io.newline() for configurer in property_configurers().values(): configurer(default_config) config.set_config(default_config, context().get_properties_file()) mcmd.io.io.newline() mcmd.io.io.info( 'The configuration file has been created at {}'.format(highlight(str(context().get_properties_file()))))
def _upgrade(default_config, user_config): mcmd.io.io.info("Some properties haven't been configured yet. Let's take a moment to fix that.") mcmd.io.io.newline() for prop, configurer in property_configurers().items(): if prop not in user_config: configurer(default_config) config.set_config(default_config, context().get_properties_file()) mcmd.io.io.newline() mcmd.io.io.info( 'The configuration file has been updated successfully ({})'.format( highlight(str(context().get_properties_file())))) exit(0)
def load_config(): yaml = YAML() default_config = yaml.load(_DEFAULT_PROPERTIES) if _is_install_required(): _install(default_config) user_config = yaml.load(get_properties_file()) if _is_upgrade_required(user_config): _upgrade(default_config, user_config) # merge the configs so that new properties and list items are added _merge(default_config, user_config) # pass result to the config module and save to disk config.set_config(default_config)
def load_config(): yaml = YAML() default_config = _try_load_yaml(yaml, _DEFAULT_PROPERTIES) if _is_install_required(): if os.getenv('MCMD_INSTALL_NON_INTERACTIVE', 'False').lower() == 'true': _install_non_interactive(default_config) else: _install(default_config) exit(0) user_config = _try_load_yaml(yaml, context().get_properties_file()) if _is_upgrade_required(user_config): _upgrade(default_config, user_config) # merge the configs so that new properties and list items are added _merge(default_config, user_config) # pass result to the config module and save to disk config.set_config(default_config, context().get_properties_file())
def _install_non_interactive(default_config): config.set_config(default_config, context().get_properties_file()) config.set_non_interactive(True) mcmd.io.io.info( 'The configuration file has been created at {}'.format(highlight(str(context().get_properties_file()))))