Ejemplo n.º 1
0
def check_parent_project(toc, project_name, project_path):
    """ Check if the qibuild project was not found because
    there was a missing
    <project src= ... />  in the parent qiproject.xml file

    """
    parent_proj = get_parent_project(toc, project_path)
    if not parent_proj:
        return
    parent_qiproj = os.path.join(parent_proj.path, "qiproject.xml")
    if not os.path.exists(parent_qiproj):
        return
    question = "Add the path to project %s to its parent qiproject.xml"
    question = question % (project_name)
    answer = qisys.interact.ask_yes_no(question, default=True)
    if answer:
        ui.info("Patching", parent_qiproj)
        tree = qixml.read(parent_qiproj)
        child_src = os.path.relpath(project_path, parent_proj.path)
        child_src = qisys.sh.to_posix_path(child_src)
        to_add = qixml.etree.Element("project")
        to_add.set("src", child_src)
        tree.getroot().append(to_add)
        qixml.write(tree, parent_qiproj)
        toc.projects = list()
        toc.worktree.load()
        toc.update_projects()
Ejemplo n.º 2
0
    def write(self, location):
        """ Write configuration back to a config file

        """
        # FIXME: remove existing <depends> element first ...
        project_tree = self.tree.getroot()
        if not project_tree:
            project_tree = etree.Element("project")
            self.tree = etree.ElementTree(element = project_tree)
        project_tree.set("name", self.name)

        both_deps = self.depends.intersection(self.rdepends)
        if both_deps:
            both_deps_tree = etree.Element("depends")
            both_deps_tree.set("buildtime", "true")
            both_deps_tree.set("runtime"  , "true")
            both_deps_tree.set("names", " ".join(both_deps))
            project_tree.append(both_deps_tree)

        runtime_only = self.rdepends - self.depends
        if runtime_only:
            runtime_tree = etree.Element("depends")
            runtime_tree.set("runtime", "true")
            runtime_tree.set("names", " ".join(runtime_only))
            project_tree.append(runtime_tree)

        build_only = self.depends - self.rdepends
        if build_only:
            build_tree = etree.Element("depends")
            build_tree.set("buildtime", "true")
            build_tree.set("names", " ".join(build_only))
            project_tree.append(build_tree)

        qixml.write(self.tree, location)
Ejemplo n.º 3
0
    def write(self, xml_path=None):
        """ Write back the new config

        """
        if not xml_path:
            xml_path = get_global_cfg_path()

        def get_name(x):
            " helper functions to sort elements "
            return x.name

        qibuild_tree = etree.Element("qibuild")
        qibuild_tree.set("version", "1")
        build_tree = self.build.tree()
        qibuild_tree.append(build_tree)
        defaults_tree = self.defaults.tree()
        qibuild_tree.append(defaults_tree)
        configs = self.configs.values()
        configs.sort(key=get_name)
        for config in configs:
            config_tree = config.tree()
            qibuild_tree.append(config_tree)
        ides = self.ides.values()
        ides.sort(key=get_name)
        for ide in ides:
            ide_tree = ide.tree()
            qibuild_tree.append(ide_tree)
        servers = self.servers.values()
        for server in servers:
            server_tree = server.tree()
            qibuild_tree.append(server_tree)

        qixml.write(qibuild_tree, xml_path)
Ejemplo n.º 4
0
    def dump(self):
        """
        Dump self to the worktree.xml file

        """
        dot_qi = os.path.join(self.root, ".qi")
        qisys.sh.mkdir(dot_qi, recursive=True)
        worktree_xml = os.path.join(self.root, ".qi", "worktree.xml")
        qixml.write(self.xml_tree, worktree_xml)
Ejemplo n.º 5
0
def add_profile(xml_path, profile):
    """ Add a new profile to an XML file

    """
    tree = qixml.read(xml_path)
    root = tree.getroot()
    profiles = root.find("profiles")
    if profiles is None:
        profiles = qixml.etree.Element("profiles")
        root.append(profiles)
    profiles.append(profile.elem())
    qixml.write(tree, xml_path)
Ejemplo n.º 6
0
 def write_local_config(self, local_xml_path):
     """ Dump local settings to a xml file """
     local_tree = self.local.tree()
     qixml.write(local_tree, local_xml_path)