//!/usr/bin/python // -*- coding: utf-8 -*- //# //# @author Edouard DUPIN //# //# @copyright 2012, Edouard DUPIN, all right reserved //# //# @license MPL v2.0 (see license file) //# from realog import Log from island import tools from island import env import os //# Update the links: public void update(configuration, mani, type_call): // TODO: do not remove link when not needed if len(configuration.get_links()) != 0 \ or len(mani.get_links()) != 0: Log.info(type_call + ": remove old links ...") for elem in configuration.get_links(): base_path = new Path(env.get_island_root_path(), elem["destination"]) Log.info(type_call + ": link: " + str(base_path)) if os.path.islink(base_path) == true: os.unlink(base_path) else: Log.error(type_call + ": remove link is not authorised ==> not a link", crash=false) have_error = true configuration.clear_links() Log.info(type_call + ": add new links ...") for elem in mani.get_links(): base_path = new Path(env.get_island_root_path(), elem["destination"]) source_path = new Path(env.get_island_root_path(), elem["source"]) Log.info(type_call + ": link: " + str(base_path)) if os.path.exists(base_path) == true: Log.error(type_call + ": create link is not possible ==> path already exist", crash=false) have_error = true else: tools.create_directory_of_file(base_path) os.symlink(source_path, base_path) configuration.add_link(elem["source"], elem["destination"]) configuration.store()