def create_zoo_config(physical_path, config: dict): """ Saves zoo app config to .zoo file :param physical_path: path to app :param config: zoo app config as dict """ logging.debug("physical_path='{0}', settings={1}".format( physical_path, config)) physical_path = os.path.join(physical_path, '.zoo') if "description" in config: config["description"] = Literal(config["description"]) if "find_installed_command" in config: config["find_installed_command"] = Literal( config["find_installed_command"]) if "install_command" in config: config["install_command"] = Literal(config["install_command"]) if "uninstall_command" in config: config["uninstall_command"] = Literal(config["uninstall_command"]) if "upgrade_command" in config: config["upgrade_command"] = Literal(config["upgrade_command"]) YamlHelper.save(config, physical_path)
def create_zoo_config(physical_path, config: dict): """ Saves zoo app config to .zoo file :param physical_path: path to app :param config: zoo app config as dict """ logging.debug("physical_path='{0}', settings={1}".format(physical_path, config)) physical_path = os.path.join(physical_path, '.zoo') YamlHelper.save(config, physical_path)
def update_zoo_config(self, site_name, virt_path, new_config): """ Writes zoo app config to .zoo file if new_config is empty then just write empty .zoo file (parent app disabled) :param site_name: site name :param virt_path: virtual path :param new_config: zoo app config as dict """ root_path = self.map_path(site_name, virt_path) zoo_config_path = os.path.join(root_path, ".zoo") config = get_zoo_config(zoo_config_path) or {} app = config.get('application') # disabled ability if 'selected-engine' in new_config: new_engine = new_config.get('selected-engine') if 'parameters' in app: app['parameters']['selected-engine'] = new_engine else: app['parameters'] = OrderedDict() app['parameters']['selected-engine'] = new_engine if 'engines' in new_config: engines = new_config.get('engines') app['engines'] = engines if 'locations' in new_config: app['locations'] = new_config['locations'] if "description" in app: app["description"] = Literal(app["description"]) if "find_installed_command" in app: app["find_installed_command"] = Literal( app["find_installed_command"]) if "install_command" in app: app["install_command"] = Literal(app["install_command"]) if "uninstall_command" in app: app["uninstall_command"] = Literal(app["uninstall_command"]) if "upgrade_command" in app: app["upgrade_command"] = Literal(app["upgrade_command"]) # save .zoo YamlHelper.save(config, zoo_config_path)
def update_zoo_config(self, site_name, virt_path, new_config): """ Writes zoo app config to .zoo file if new_config is empty then just write empty .zoo file (parent app disabled) :param site_name: site name :param virt_path: virtual path :param new_config: zoo app config as dict """ root_path = self.map_path(site_name, virt_path) zoo_config_path = os.path.join(root_path, ".zoo") config = get_zoo_config(zoo_config_path) or {} app = config.get('application') # disabled ability if 'selected-engine' in new_config : new_engine = new_config.get('selected-engine') if 'parameters' in app: app['parameters']['selected-engine'] = new_engine else: app['parameters'] = OrderedDict() app['parameters']['selected-engine'] = new_engine if 'engines' in new_config: engines = new_config.get('engines') app['engines'] = engines if 'locations' in new_config: app['locations'] = new_config['locations'] if "description" in app: app["description"] = Literal(app["description"]) if "find_installed_command" in app: app["find_installed_command"] = Literal(app["find_installed_command"]) if "install_command" in app: app["install_command"] = Literal(app["install_command"]) if "uninstall_command" in app: app["uninstall_command"] = Literal(app["uninstall_command"]) if "upgrade_command" in app: app["upgrade_command"] = Literal(app["upgrade_command"]) # save .zoo YamlHelper.save(config, zoo_config_path)
def update_zoo_config(self, site_name, virt_path, new_config): """ Writes zoo app config to .zoo file if new_config is empty then just write empty .zoo file (parent app disabled) :param site_name: site name :param virt_path: virtual path :param new_config: zoo app config as dict """ root_path = self.map_path(site_name, virt_path) zoo_config_path = os.path.join(root_path, ".zoo") config = get_zoo_config(zoo_config_path) or {} # check engine was updated orig_engine = config.get('engine') new_engine = new_config.get('engine') if orig_engine != new_engine: # update env variables from new engine # application in .zoo app = config.get('application') if app: # engines section engines = app['engines'] # search engine by name engine = search_dict_in_list_by_attr(engines, 'engine', new_engine) if engine: # engine envs new_engine_envs = engine.get('environment_variables') if new_engine_envs: if not 'environment_variables' in new_config: new_config['environment_variables'] = {} new_config['environment_variables'].update(new_engine_envs) # update .zoo with new config config.update(new_config) # save .zoo YamlHelper.save(config, zoo_config_path)
def create_zoo_config(physical_path, config: dict): """ Saves zoo app config to .zoo file :param physical_path: path to app :param config: zoo app config as dict """ logging.debug("physical_path='{0}', settings={1}".format(physical_path, config)) physical_path = os.path.join(physical_path, '.zoo') if "description" in config: config["description"] = Literal(config["description"]) if "find_installed_command" in config: config["find_installed_command"] = Literal(config["find_installed_command"]) if "install_command" in config: config["install_command"] = Literal(config["install_command"]) if "uninstall_command" in config: config["uninstall_command"] = Literal(config["uninstall_command"]) if "upgrade_command" in config: config["upgrade_command"] = Literal(config["upgrade_command"]) YamlHelper.save(config, physical_path)
def save(self): """ Сохраняет настройки в файл. """ self.assert_exist(os.path.dirname(self.path)) YamlHelper.save(self.source, self.path)