Exemplo n.º 1
0
    def make_collection_index(self, path, projectCollections, default_language):
        doc = piksemel.newDocument("YALI")
        for collection in projectCollections:
            collectionTag = doc.insertTag("Collection")
            if collection.default:
                collectionTag.setAttribute("default", collection.default)
            collectionTag.insertTag("id").insertData(collection._id)
            collectionTag.insertTag("icon").insertData(os.path.basename(collection.icon))
            translationsTag = collectionTag.insertTag("translations")
            translationsTag.setAttribute("default", default_language)
            for languageCode, translation in collection.translations.items():
                translationTag = translationsTag.insertTag("translation")
                translationTag.setAttribute("language", languageCode)
                translationTag.insertTag("title").insertData(translation[0])
                translationTag.insertTag("description").insertData(translation[1])

        f = file(os.path.join(path, "collection.xml"), "w")
        f.write(doc.toPrettyString())
        f.close()

        import hashlib
        f = file(os.path.join(path, "collection.xml.sha1sum"), "w")
        s = hashlib.sha1()
        s.update(doc.toPrettyString())
        f.write(s.hexdigest())
        f.close()
Exemplo n.º 2
0
    def get_repo_doc(self, repo_name):
        if not self.has_repo(repo_name):
            raise RepoError(_("Repository %s does not exist.") % repo)

        repo = self.get_repo(repo_name)

        index_path = repo.indexuri.get_uri()

        #FIXME Local index files should also be cached.
        if File.is_compressed(index_path) or repo.indexuri.is_remote_file():
            index = os.path.basename(index_path)
            index_path = pisi.util.join_path(ctx.config.index_dir(),
                                             repo_name, index)

            if File.is_compressed(index_path):
                index_path = os.path.splitext(index_path)[0]

        if not os.path.exists(index_path):
            ctx.ui.warning(_("%s repository needs to be updated") % repo_name)
            return piksemel.newDocument("PISI")

        try:
            return piksemel.parse(index_path)
        except Exception as e:
            raise RepoError(_("Error parsing repository index information. Index file does not exist or is malformed."))
Exemplo n.º 3
0
    def make_index(self, package_list):
        doc = piksemel.newDocument("PISI")

        # since new PiSi (pisi 2) needs component info in index file, we need to copy it from original index that user specified
        indexpath = fetch_uri(self.base_uri, self.cache_dir, self.index_name, None, False)
        if indexpath.endswith(".bz2"):
            import bz2
            data = open(indexpath).read()
            data = bz2.decompress(data)
            doc_index = piksemel.parseString(data)
        elif indexpath.endswith(".xz"):
            try:
                import lzma
            except ImportError:
                print "Install python-pyliblzma package, or try a different index format."
                return

            data = open(indexpath).read()
            data = lzma.decompress(data)
            doc_index = piksemel.parseString(data)
        else:
            doc_index = piksemel.parse(indexpath)

        # old PiSi needs obsoletes list, so we need to copy it too.
        for comp_node in doc_index.tags("Distribution"):
            doc.insertNode(comp_node)

        for name in package_list:
            doc.insertNode(self.packages[name].node)

        for comp_node in doc_index.tags("Component"):
            doc.insertNode(comp_node)

        return doc.toPrettyString()
Exemplo n.º 4
0
    def make_collection_index(self, path, projectCollections,
                              default_language):
        doc = piksemel.newDocument("YALI")
        for collection in projectCollections:
            collectionTag = doc.insertTag("Collection")
            if collection.default:
                collectionTag.setAttribute("default", collection.default)
            collectionTag.insertTag("id").insertData(collection._id)
            collectionTag.insertTag("icon").insertData(
                os.path.basename(collection.icon))
            translationsTag = collectionTag.insertTag("translations")
            translationsTag.setAttribute("default", default_language)
            for languageCode, translation in collection.translations.items():
                translationTag = translationsTag.insertTag("translation")
                translationTag.setAttribute("language", languageCode)
                translationTag.insertTag("title").insertData(translation[0])
                translationTag.insertTag("description").insertData(
                    translation[1])

        f = file(os.path.join(path, "collection.xml"), "w")
        f.write(doc.toPrettyString())
        f.close()

        import hashlib
        f = file(os.path.join(path, "collection.xml.sha1sum"), "w")
        s = hashlib.sha1()
        s.update(doc.toPrettyString())
        f.write(s.hexdigest())
        f.close()
Exemplo n.º 5
0
 def save(self, filename):
     doc = piksemel.newDocument("PardusmanProject")
     doc.setAttribute("type", self.type)
     doc.setAttribute("media", str(self.media))
     if self.title:
         doc.insertTag("Title").insertData(self.title)
     if self.work_dir:
         doc.insertTag("WorkDir").insertData(self.work_dir)
     if self.release_files:
         doc.insertTag("ReleaseFiles").insertData(self.release_files)
     if self.exparams:
         doc.insertTag("ExtraParameters").insertData(self.exparams)
     if self.repo_uri:
         paks = doc.insertTag("PackageSelection")
         paks.setAttribute("repo_uri", self.repo_uri)
         self.selected_components.sort()
         for item in self.selected_components:
             paks.insertTag("SelectedComponent").insertData(item)
         self.selected_packages.sort()
         for item in self.selected_packages:
             paks.insertTag("SelectedPackage").insertData(item)
         self.all_packages.sort()
         for item in self.all_packages:
             paks.insertTag("Package").insertData(item)
     data = doc.toPrettyString()
     f = file(filename, "w")
     f.write(data)
     f.close()
Exemplo n.º 6
0
    def make_index(self, package_list):
        doc = piksemel.newDocument("PISI")

        # since new PiSi (pisi 2) needs component info in index file, we need to copy it from original index that user specified
        indexpath = fetch_uri(self.base_uri, self.cache_dir, self.index_name,
                              None, False)
        if indexpath.endswith(".bz2"):
            import bz2
            data = file(indexpath).read()
            data = bz2.decompress(data)
            doc_index = piksemel.parseString(data)
        else:
            doc_index = piksemel.parse(indexpath)

        # old PiSi needs obsoletes list, so we need to copy it too.
        for comp_node in doc_index.tags("Distribution"):
            doc.insertNode(comp_node)

        for name in package_list:
            doc.insertNode(self.packages[name].node)

        for comp_node in doc_index.tags("Component"):
            doc.insertNode(comp_node)

        return doc.toPrettyString()
Exemplo n.º 7
0
def setKeymap(layout, variant=""):
    import piksemel

    # FDI file for evdev driver
    doc = piksemel.newDocument("deviceinfo")
    device = doc.insertTag("device")

    match = device.insertTag("match")
    match.setAttribute("key", "info.capabilities")
    match.setAttribute("contains", "input.keys")

    merge = match.insertTag("merge")
    merge.setAttribute("key", "input.xkb.layout")
    merge.setAttribute("type", "string")
    merge.insertData(layout)

    merge = match.insertTag("merge")
    merge.setAttribute("key", "input.xkb.variant")
    merge.setAttribute("type", "string")
    if variant:
        merge.insertData(variant)

    f = file("/etc/hal/fdi/policy/10-keymap.fdi", "w")
    f.write(doc.toPrettyString())

    # zorg's config file
    saveKeymap(layout, variant)
Exemplo n.º 8
0
    def get_repo_doc(self, repo_name):
        if not self.has_repo(repo_name):
            raise RepoError(_("Repository %s does not exist.") % repo)

        repo = self.get_repo(repo_name)

        index_path = repo.indexuri.get_uri()

        #FIXME Local index files should also be cached.
        if File.is_compressed(index_path) or repo.indexuri.is_remote_file():
            index = os.path.basename(index_path)
            index_path = pisi.util.join_path(ctx.config.index_dir(),
                                             repo_name, index)

            if File.is_compressed(index_path):
                index_path = os.path.splitext(index_path)[0]

        if not os.path.exists(index_path):
            ctx.ui.warning(_("%s repository needs to be updated") % repo_name)
            return piksemel.newDocument("PISI")

        try:
            return piksemel.parse(index_path)
        except Exception, e:
            raise RepoError(_("Error parsing repository index information. Index file does not exist or is malformed."))
Exemplo n.º 9
0
    def _get_doc(self):
        if self._doc is None:
            repos_file = os.path.join(ctx.config.info_dir(), ctx.const.repos)
            if os.path.exists(repos_file):
                self._doc = piksemel.parse(repos_file)
            else:
                self._doc = piksemel.newDocument("REPOS")

        return self._doc
Exemplo n.º 10
0
 def toXML(self):
     doc = piksemel.newDocument("Domain")
     doc.setAttribute("name", self.name)
     doc.insertTag("Host").insertData(self.host)
     doc.insertTag("BaseDN").insertData(self.base_dn)
     bind = doc.insertTag("Bind")
     bind.insertTag("DN").insertData(self.bind_dn)
     bind.insertTag("Password").insertData(self.bind_password)
     return doc
Exemplo n.º 11
0
    def _get_doc(self):
        if self._doc is None:
            repos_file = os.path.join(ctx.config.info_dir(), ctx.const.repos)
            if os.path.exists(repos_file):
                self._doc = piksemel.parse(repos_file)
            else:
                self._doc = piksemel.newDocument("REPOS")

        return self._doc
Exemplo n.º 12
0
 def save(self):
     path = self.configFile()
     doc = piksemel.newDocument("AhenkLider")
     doms = doc.insertTag("Domains")
     item = self.firstChild()
     while item:
         doms.insertNode(item.item.toXML())
         item = item.nextSibling()
     file(path, "w").write(doc.toPrettyString())
Exemplo n.º 13
0
    def backupInstallData(self):
        import piksemel

        def insert(root, tag, data):
            _ = root.insertTag(tag)
            _.insertData(str(data))

        # let create a yali piksemel..
        yali = piksemel.newDocument("yali")

        # let store keymap and language options
        insert(yali, "language", ctx.consts.lang)
        insert(yali, "keymap", ctx.installData.keyData["xkblayout"])
        insert(yali, "variant", ctx.installData.keyData["xkbvariant"])

        # we will store passwords as shadowed..
        insert(yali, "root_password",
               yali4.sysutils.getShadowed(ctx.installData.rootPassword or ""))

        # time zone..
        insert(yali, "timezone", ctx.installData.timezone)

        # hostname ..
        insert(yali, "hostname", ctx.installData.hostName)

        # users ..
        if len(yali4.users.pending_users) > 0:
            users = yali.insertTag("users")
        for u in yali4.users.pending_users:
            user = users.insertTag("user")
            insert(user, "username", u.username)
            insert(user, "realname", u.realname)
            insert(user, "password", yali4.sysutils.getShadowed(u.passwd))
            insert(user, "groups", ",".join(u.groups))

        # partitioning ..
        devices = []
        for dev in yali4.storage.devices:
            if dev.getTotalMB() >= ctx.consts.min_root_size:
                devices.append(dev.getPath())

        partitioning = yali.insertTag("partitioning")
        partitioning.setAttribute(
            "partition_type", {
                methodEraseAll: "auto",
                methodUseAvail: "smartAuto",
                methodManual: "manual"
            }[ctx.installData.autoPartMethod])
        if not ctx.installData.autoPartMethod == methodManual:
            try:
                partitioning.insertData(
                    "disk%d" %
                    devices.index(ctx.installData.autoPartDev.getPath()))
            except:
                partitioning.insertData(ctx.installData.autoPartDev.getPath())

        ctx.installData.sessionLog = yali.toPrettyString()
Exemplo n.º 14
0
def saveDeviceInfo(card):
    if not os.path.exists(consts.config_dir):
        os.mkdir(consts.config_dir, 0755)

    try:
        doc = piksemel.parse(consts.config_file)
    except OSError:
        doc = piksemel.newDocument("ZORG")

    for tag in doc.tags("Card"):
        if tag.getAttribute("busId") == card.bus_id:
            tag.hide()
            break

    cardTag = doc.insertTag("Card")
    cardTag.setAttribute("busId", card.bus_id)

    addTag(cardTag, "VendorId", card.vendor_id)
    addTag(cardTag, "ProductId", card.product_id)

    if card.driver:
        addTag(cardTag, "Driver", card.driver)

    if card.depth:
        addTag(cardTag, "Depth", str(card.depth))

    # Save output info
    outputs = cardTag.insertTag("Outputs")
    for name, output in card.outputs.items():
        out = outputs.insertTag("Output")
        out.setAttribute("name", name)
        addTag(out, "Enabled", "true" if output.enabled else "false")
        addTag(out, "Ignored", "true" if output.ignored else "false")
        if output.mode:
            addTag(out, "Mode", output.mode)
        if output.refresh_rate:
            addTag(out, "RefreshRate", output.refresh_rate)
        if output.rotation:
            addTag(out, "Rotation", output.rotation)
        if output.right_of:
            addTag(out, "RightOf", output.right_of)
        if output.below:
            addTag(out, "Below", output.below)

        if name in card.monitors:
            mon = card.monitors[name]
            monitor = out.insertTag("Monitor")
            addTag(monitor, "Vendor", mon.vendor)
            addTag(monitor, "Model", mon.model)
            addTag(monitor, "HorizSync", mon.hsync)
            addTag(monitor, "VertRefresh", mon.vref)

    f = open(consts.config_file, "w")
    f.write(doc.toPrettyString().replace("\n\n", ""))
Exemplo n.º 15
0
def saveDeviceInfo(card):
    if not os.path.exists(consts.config_dir):
        os.mkdir(consts.config_dir, 0755)

    try:
        doc = piksemel.parse(consts.config_file)
    except OSError:
        doc = piksemel.newDocument("ZORG")

    for tag in doc.tags("Card"):
        if tag.getAttribute("busId") == card.bus_id:
            tag.hide()
            break

    cardTag = doc.insertTag("Card")
    cardTag.setAttribute("busId", card.bus_id)

    addTag(cardTag, "VendorId", card.vendor_id)
    addTag(cardTag, "ProductId", card.product_id)

    if card.driver:
        addTag(cardTag, "Driver", card.driver)

    if card.depth:
        addTag(cardTag, "Depth", str(card.depth))

    # Save output info
    outputs = cardTag.insertTag("Outputs")
    for name, output in card.outputs.items():
        out = outputs.insertTag("Output")
        out.setAttribute("name", name)
        addTag(out, "Enabled", "true" if output.enabled else "false")
        addTag(out, "Ignored", "true" if output.ignored else "false")
        if output.mode:
            addTag(out, "Mode", output.mode)
        if output.refresh_rate:
            addTag(out, "RefreshRate", output.refresh_rate)
        if output.rotation:
            addTag(out, "Rotation", output.rotation)
        if output.right_of:
            addTag(out, "RightOf", output.right_of)
        if output.below:
            addTag(out, "Below", output.below)

        if name in card.monitors:
            mon = card.monitors[name]
            monitor = out.insertTag("Monitor")
            addTag(monitor, "Vendor", mon.vendor)
            addTag(monitor, "Model", mon.model)
            addTag(monitor, "HorizSync", mon.hsync)
            addTag(monitor, "VertRefresh", mon.vref)

    f = open(consts.config_file, "w")
    f.write(doc.toPrettyString().replace("\n\n", ""))
Exemplo n.º 16
0
    def backupInstallData(self):
        import piksemel

        def insert(root,tag,data):
            _ = root.insertTag(tag)
            _.insertData(str(data))

        # let create a yali piksemel..
        yali = piksemel.newDocument("yali")

        # let store keymap and language options
        # yali.insertTag("language").insertData(str(ctx.consts.lang))
        insert(yali,"language",ctx.consts.lang)
        insert(yali,"keymap",ctx.installData.keyData["xkblayout"])
        insert(yali,"variant",ctx.installData.keyData["xkbvariant"])

        # we will store passwords as shadowed..
        insert(yali,"root_password",yali.sysutils.getShadowed(ctx.installData.rootPassword or ""))

        # time zone..
        insert(yali,"timezone",ctx.installData.timezone)

        # hostname ..
        insert(yali,"hostname",ctx.installData.hostName)

        # users ..
        if len(yali.users.pending_users) > 0:
            users = yali.insertTag("users")
        for u in yali.users.pending_users:
            user = users.insertTag("user")
            insert(user,"username",u.username)
            insert(user,"realname",u.realname)
            insert(user,"password",yali.sysutils.getShadowed(u.passwd))
            insert(user,"groups",",".join(u.groups))

        # partitioning ..
        devices = []
        for dev in yali.storage.devices:
            if dev.getTotalMB() >= ctx.consts.min_root_size:
                devices.append(dev.getPath())

        partitioning = yali.insertTag("partitioning")
        partitioning.setAttribute("partition_type",
                                 {methodEraseAll:"auto",
                                  methodUseAvail:"smartAuto",
                                  methodManual:"manual"}[ctx.installData.autoPartMethod])
        if not ctx.installData.autoPartMethod == methodManual:
            try:
                partitioning.insertData("disk%d" % devices.index(ctx.installData.autoPartDev.getPath()))
            except:
                partitioning.insertData(ctx.installData.autoPartDev.getPath())

        ctx.installData.sessionLog = yali.toPrettyString()
Exemplo n.º 17
0
 def toXML(self, filename=None):
     """Save current configuration to specified filename. (default: ~/.lider.xml)"""
     if not filename:
         filename = os.path.join(os.environ["HOME"], ".lider.xml")
     doc = piksemel.newDocument("Lider")
     for connection in self.connections:
         dom = doc.insertTag("Domain")
         dom.setAttribute("label", connection.label)
         dom.insertTag("Host").insertData(connection.host)
         dom.insertTag("BaseDN").insertData(connection.base_dn)
         if connection.bind_dn and connection.bind_password:
             bind = dom.insertTag("Bind")
             bind.insertTag("DN").insertData(connection.bind_dn)
             bind.insertTag("Password").insertData(connection.bind_password)
     file(filename, "w").write(doc.toPrettyString())
Exemplo n.º 18
0
    def get_repo_doc(self, repo_name):
        repo = self.get_repo(repo_name)
        index = os.path.basename(repo.indexuri.get_uri())
        index_path = pisi.util.join_path(ctx.config.index_dir(), repo_name, index)

        if index_path.endswith("bz2"):
            index_path = index_path.split(".bz2")[0]

        if not os.path.exists(index_path):
            ctx.ui.warning(_("%s repository needs to be updated") % repo_name)
            return piksemel.newDocument("PISI")

        try:
            return piksemel.parse(index_path)
        except Exception, e:
            raise RepoError(_("Error parsing repository index information. Index file does not exist or is malformed."))
Exemplo n.º 19
0
    def createProjectFile(self, filename):
        import piksemel

        doc = piksemel.newDocument("PardusmanProject")
        doc.setAttribute("type", self.projectData["type"])
        doc.setAttribute("media", self.projectData["media"])
        #        doc.insertTag("Title").insertData(values["Project Name"])
        if self.projectData["type"] == "live":
            users = doc.insertTag("Users")
            for username in self.projectData["user"].iterkeys():
                user = users.insertTag("User")
                if username == "root":
                    user.setAttribute("username", username)
                    user.setAttribute("passwd",
                                      self.projectData["user"]["root"][0])
                else:
                    user.setAttribute("username", username)
                    user.setAttribute("name",
                                      self.projectData["user"][username][0])
                    user.setAttribute("passwd",
                                      self.projectData["user"][username][1])
                    user.setAttribute(
                        "isAdmin", str(self.projectData["user"][username][2]))
            grub = doc.insertTag("grub")
            grub.insertTag("image").insertData(
                self.projectData["grub"]["image"])
            for option in self.projectData["grub"]["options"]:
                grub.insertTag("option").insertData(option)
        doc.insertTag("WorkDir").insertData("/tmp/pw_tmp")

        paks = doc.insertTag("PackageSelection")
        paks.setAttribute("repo_uri", "|".join(self.projectData["repo"]))
        #values["Components"].sort()
        #for item in values["Components"]:
        #   paks.insertTag("SelectedComponent").insertData(item)
        #values["Packages"].sort()
        #for item in values["Packages"]:
        #    paks.insertTag("SelectedPackage").insertData(item)

        data = doc.toPrettyString()
        f = file(filename, "w")
        f.write(data)
        f.close()
Exemplo n.º 20
0
    def get_repo_doc(self, repo_name):
        repo = self.get_repo(repo_name)
        index = os.path.basename(repo.indexuri.get_uri())
        index_path = pisi.util.join_path(ctx.config.index_dir(), repo_name,
                                         index)

        if index_path.endswith("bz2"):
            index_path = index_path.split(".bz2")[0]

        if not os.path.exists(index_path):
            ctx.ui.warning("%s repository needs to be updated" % repo_name)
            return piksemel.newDocument("PISI")

        try:
            return piksemel.parse(index_path)
        except Exception, e:
            raise RepoError(
                "Error parsing repository index information. Index file does not exist or is malformed."
            )
Exemplo n.º 21
0
 def toString(self, doc=None):
     if not doc:
         doc = piksemel.newDocument(self.root_tag)
         self.toString(doc)
         return doc.toPrettyString()
     
     cdata, attrs, tags = self._autoPiksScan()
     attrs = attrs.values()
     attrs.sort(key=lambda x: x.varname)
     tags = tags.values()
     tags.sort(key=lambda x: x.order)
     
     for attr in attrs:
         attr.serialize(self, doc)
     
     if cdata:
         cdata.serialize(self, doc)
     else:
         for tag in tags:
             tag.serialize(self, doc)
Exemplo n.º 22
0
    def toString(self, doc=None):
        if not doc:
            doc = piksemel.newDocument(self.root_tag)
            self.toString(doc)
            return doc.toPrettyString()

        cdata, attrs, tags = self._autoPiksScan()
        attrs = list(attrs.values())
        attrs.sort(key=lambda x: x.varname)
        tags = list(tags.values())
        tags.sort(key=lambda x: x.order)

        for attr in attrs:
            attr.serialize(self, doc)

        if cdata:
            cdata.serialize(self, doc)
        else:
            for tag in tags:
                tag.serialize(self, doc)
Exemplo n.º 23
0
def saveKeymap(layout, variant=""):
    if not os.path.exists(consts.config_dir):
        os.mkdir(consts.config_dir, 0755)

    try:
        doc = piksemel.parse(consts.config_file)
    except OSError:
        doc = piksemel.newDocument("ZORG")

    keyboardTag = doc.getTag("Keyboard")

    if keyboardTag:
        keyboardTag.hide()

    keyboardTag = doc.insertTag("Keyboard")
    keyboardTag.insertTag("Layout").insertData(layout)
    if variant:
        keyboardTag.insertTag("Variant").insertData(variant)

    f = file(consts.config_file, "w")
    f.write(doc.toPrettyString().replace("\n\n", ""))
Exemplo n.º 24
0
def saveKeymap(layout, variant=""):
    if not os.path.exists(consts.config_dir):
        os.mkdir(consts.config_dir, 0755)

    try:
        doc = piksemel.parse(consts.config_file)
    except OSError:
        doc = piksemel.newDocument("ZORG")

    keyboardTag = doc.getTag("Keyboard")

    if keyboardTag:
        keyboardTag.hide()

    keyboardTag = doc.insertTag("Keyboard")
    keyboardTag.insertTag("Layout").insertData(layout)
    if variant:
        keyboardTag.insertTag("Variant").insertData(variant)

    f = file(consts.config_file, "w")
    f.write(doc.toPrettyString().replace("\n\n", ""))
Exemplo n.º 25
0
def saveKeymap(layout, variant="basic"):
    if not os.path.exists(zorgConfigDir):
        os.mkdir(zorgConfigDir, 0755)

    configFile = os.path.join(zorgConfigDir, zorgConfig)

    try:
        doc = piksemel.parse(configFile)
    except OSError:
        doc = piksemel.newDocument("ZORG")

    keyboardTag = doc.getTag("Keyboard")

    if keyboardTag:
        keyboardTag.hide()

    keyboardTag = doc.insertTag("Keyboard")
    keyboardTag.insertTag("Layout").insertData(layout)
    keyboardTag.insertTag("Variant").insertData(variant)

    file(configFile, "w").write(doc.toPrettyString().replace("\n\n", ""))
Exemplo n.º 26
0
def setKeymap(layout, variant="basic"):
    import piksemel

    # FDI file for evdev driver
    doc = piksemel.newDocument("deviceinfo")
    device = doc.insertTag("device")

    match = device.insertTag("match")
    match.setAttribute("key", "info.capabilities")
    match.setAttribute("contains", "input.keys")

    merge = match.insertTag("merge")
    merge.setAttribute("key", "input.xkb.layout")
    merge.setAttribute("type", "string")
    merge.insertData(layout)

    merge = match.insertTag("merge")
    merge.setAttribute("key", "input.xkb.variant")
    merge.setAttribute("type", "string")
    if variant:
        merge.insertData(variant)

    file("/etc/hal/fdi/policy/10-keymap.fdi", "w").write(doc.toPrettyString())

    # zorg's config file
    saveKeymap(layout, variant)

    # xorg.conf
    if os.path.exists(xorgConf):
        parser = XorgParser()
        parser.parseFile(xorgConf)

        inputs = parser.getSections("InputDevice")

        for input in inputs:
            if input.get("Driver") == "kbd":
                input.options["XkbLayout"] = layout
                input.options["XkbVariant"] = variant

        file(xorgConf, "w").write(parser.toString())
Exemplo n.º 27
0
def setKeymap(layout, variant="basic"):
    import piksemel

    # FDI file for evdev driver
    doc = piksemel.newDocument("deviceinfo")
    device = doc.insertTag("device")

    match = device.insertTag("match")
    match.setAttribute("key", "info.capabilities")
    match.setAttribute("contains", "input.keys")

    merge = match.insertTag("merge")
    merge.setAttribute("key", "input.xkb.layout")
    merge.setAttribute("type", "string")
    merge.insertData(layout)

    merge = match.insertTag("merge")
    merge.setAttribute("key", "input.xkb.variant")
    merge.setAttribute("type", "string")
    if variant:
        merge.insertData(variant)

    file("/etc/hal/fdi/policy/10-keymap.fdi", "w").write(doc.toPrettyString())

    # zorg's config file
    saveKeymap(layout, variant)

    # xorg.conf
    if os.path.exists(xorgConf):
        parser = XorgParser()
        parser.parseFile(xorgConf)

        inputs = parser.getSections("InputDevice")

        for input in inputs:
            if input.get("Driver") == "kbd":
                input.options["XkbLayout"] = layout
                input.options["XkbVariant"] = variant

        file(xorgConf, "w").write(parser.toString())
Exemplo n.º 28
0
    def createProjectFile(self,  filename):
        import piksemel
        
        doc = piksemel.newDocument("PardusmanProject")
        doc.setAttribute("type", self.projectData["type"])
        doc.setAttribute("media", self.projectData["media"])
#        doc.insertTag("Title").insertData(values["Project Name"])
        if self.projectData["type"] == "live":
            users = doc.insertTag("Users")
            for username in self.projectData["user"].iterkeys():
                user = users.insertTag("User")
                if username == "root":
                    user.setAttribute("username",  username)
                    user.setAttribute("passwd",  self.projectData["user"]["root"][0])
                else:
                    user.setAttribute("username",  username)
                    user.setAttribute("name",  self.projectData["user"][username][0])
                    user.setAttribute("passwd",  self.projectData["user"][username][1])
                    user.setAttribute("isAdmin",  str(self.projectData["user"][username][2]))
            grub = doc.insertTag("grub")
            grub.insertTag("image").insertData(self.projectData["grub"]["image"])
            for option in self.projectData["grub"]["options"]:
                grub.insertTag("option").insertData(option)
        doc.insertTag("WorkDir").insertData("/tmp/pw_tmp")

        paks = doc.insertTag("PackageSelection")
        paks.setAttribute("repo_uri", "|".join(self.projectData["repo"]))
        #values["Components"].sort()
        #for item in values["Components"]:
        #   paks.insertTag("SelectedComponent").insertData(item)
        #values["Packages"].sort()
        #for item in values["Packages"]:
        #    paks.insertTag("SelectedPackage").insertData(item)
    
        data = doc.toPrettyString()
        f = file(filename, "w")
        f.write(data)
        f.close()
Exemplo n.º 29
0
    def __write(self):
        self.doc = piksemel.newDocument("PISI-Offline")

        newOp = self.doc.insertTag("Operation")
        newOp.setAttribute("Type", self.op_type)
        newOp.setAttribute("Date", self.op_date)
        newOp.setAttribute("Time", self.op_time)

        Packages = newOp.insertTag("Packages")
        if self.op_type == "install":
            for pkg in self.pkgs:
                backend.pm.Iface().fetch([pkg], pkgs_path)
                Packages.insertTag("PackageURI").insertData(backend.pm.Iface().getPackageURI(pkg))
        else:
            for pkg in self.pkgs:
                Packages.insertTag("Package").insertData(pkg)

        try:
            f = open(self.filename, "w")
            f.write(self.doc.toPrettyString())
            f.close()
            return True
        except:
            raise Exception("Operation file could not written!")
Exemplo n.º 30
0
    def __write(self):
        self.doc = piksemel.newDocument("PISI-Offline")

        newOp = self.doc.insertTag("Operation")
        newOp.setAttribute("Type", self.op_type)
        newOp.setAttribute("Date", self.op_date)
        newOp.setAttribute("Time", self.op_time)

        Packages = newOp.insertTag("Packages")
        if self.op_type == "install":
            for pkg in self.pkgs:
                backend.pm.Iface().fetch([pkg], pkgs_path)
                Packages.insertTag("PackageURI").insertData(backend.pm.Iface().getPackageURI(pkg))
        else:
            for pkg in self.pkgs:
                Packages.insertTag("Package").insertData(pkg)

        try:
            f = open(self.filename, "w")
            f.write(self.doc.toPrettyString())
            f.close()
            return True
        except:
            raise Exception("Operation file could not written!")
Exemplo n.º 31
0
#!/usr/bin/env python

import piksemel as iks

doc_xml = """
<test>
    <a><b><c/></b></a>
    <item foo="lala">
        <tuktuk>blah &amp; bleh</tuktuk>
        <nanuk/>
    </item>
    <a/>
</test>
""".strip()

doc = iks.newDocument("test")
doc.insertData("\n    ")
a = doc.insertTag("a")
a.insertTag("b").insertTag("c")
doc.insertData("\n    ")
item = doc.insertTag("item")
item.setAttribute("foo", "lala")
item.insertData("\n        ")
item.insertTag("tuktuk").insertData("blah & bleh")
item.insertData("\n        ")
item.insertTag("nanuk")
item.insertData("\n    ")
doc.insertData("\n    ")
a = doc.insertTag("a")
doc.insertData("\n")
assert (doc.toString() == doc_xml)
Exemplo n.º 32
0
 def newDocument(self):
     """clear DOM"""
     self.doc = iks.newDocument(self.rootTag)
Exemplo n.º 33
0
    def save(self, filename=None):
        # Save the data into filename as pardusman project file
        doc = piksemel.newDocument("PardusmanProject")

        doc.setAttribute("type", self.type)
        doc.setAttribute("media", str(self.media))

        selected_components = []

        for comp in self.selected_components:
            selected_components.append(comp.replace('-', '.'))

        if self.title:
            doc.insertTag("Title").insertData(self.title)
        if self.work_dir:
            doc.insertTag("WorkDir").insertData(self.work_dir)
        if self.release_files:
            doc.insertTag("ReleaseFiles").insertData(self.release_files)
        if self.plugin_package:
            doc.insertTag("PluginPackage").insertData(self.plugin_package)
        if self.extra_params:
            doc.insertTag("ExtraParameters").insertData(self.extra_params)

        if self.username:
            doc.insertTag("Username").insertData(self.username)

        if self.password:
            doc.insertTag("Password").insertData(self.password)

        if self.wallpaper:
            doc.insertTag("Wallpaper").insertData(self.wallpaper)
        if self.user_contents:
            doc.insertTag("UserContents").insertData(self.user_contents)
        if self.hostname:
            doc.insertTag("Hostname").insertData(self.hostname)

        if self.repo:
            package_selection = doc.insertTag("PackageSelection")
            package_selection.setAttribute("repo", self.repo)

            # Insert components if any
            for item in selected_components:
                package_selection.insertTag("SelectedComponent").insertData(
                    item)

            for item in self.selected_packages:
                package_selection.insertTag("SelectedPackage").insertData(item)

            for item in self.all_packages:
                package_selection.insertTag("Package").insertData(item)

        if self.default_language:
            # Set the default language
            langs = doc.insertTag("LanguageSelection")
            langs.setAttribute("default_language", self.default_language)

            # Insert other supported languages if any
            for item in self.selected_languages:
                langs.insertTag("Language").insertData(item)

        # Write the file
        if not filename:
            filename = self.filename
        f = file(filename, "w")
        f.write(doc.toPrettyString())
        f.close()
Exemplo n.º 34
0
#!/usr/bin/python

import piksemel as iks

doc_xml = """
<test>
    <a><b><c/></b></a>
    <item foo="lala">
        <tuktuk>blah &amp; bleh</tuktuk>
        <nanuk/>
    </item>
    <a/>
</test>
""".strip()

doc = iks.newDocument("test")
doc.insertData("\n    ")
a = doc.insertTag("a")
a.insertTag("b").insertTag("c")
doc.insertData("\n    ")
item = doc.insertTag("item")
item.setAttribute("foo", "lala")
item.insertData("\n        ")
item.insertTag("tuktuk").insertData("blah & bleh")
item.insertData("\n        ")
item.insertTag("nanuk")
item.insertData("\n    ")
doc.insertData("\n    ")
a = doc.insertTag("a")
doc.insertData("\n")
assert doc.toString() == doc_xml
Exemplo n.º 35
0
    def save(self, filename=None):
        # Save the data into filename as pardusman project file
        doc = piksemel.newDocument("PardusmanProject")

        doc.setAttribute("type", self.type)
        doc.setAttribute("media", str(self.media))
        doc.setAttribute("compression", str(self.squashfs_comp_type))

        if self.title:
            doc.insertTag("Title").insertData(self.title)
        if self.work_dir:
            doc.insertTag("WorkDir").insertData(self.work_dir)
        if self.release_files:
            doc.insertTag("ReleaseFiles").insertData(self.release_files)
        if self.plugin_package:
            doc.insertTag("PluginPackage").insertData(self.plugin_package)
        if self.extra_params:
            doc.insertTag("ExtraParameters").insertData(self.extra_params)

        if self.package_collections:
            collections = doc.insertTag("PackageCollections")
            for collection in self.package_collections:
                packageCollection = collections.insertTag("PackageCollection")
                print "collection.name:%s" % collection.uniqueTag
                print "collection.icon:%s" % collection.icon
                print "collection.Title:%s" % collection.title
                print "collection.Description:%s" % collection.descriptionSelection.description
                print "collection.packageSelection.repoURI:%s" % collection.packageSelection.repoURI

                # Writes if collection is default
                if collection.default:
                    packageCollection.setAttribute("default", collection.default)

                # Writes Collection identifiers
                packageCollection.insertTag("Name").insertData(collection.uniqueTag)
                packageCollection.insertTag("Icon").insertData(collection.icon)
                packageCollection.insertTag("Title").insertData(collection.title)

                # Writes Description
                collectionDescription = packageCollection.insertTag("DescriptionSelection")
                collectionDescription.insertTag("Description").insertData(collection.descriptionSelection.description)
                for languageCode, translation in collection.descriptionSelection.translations.items():
                    collectionTranslation = collectionDescription.insertTag("Translation")
                    collectionTranslation.setAttribute("code", languageCode)
                    collectionTranslation.insertData(translation)

                # Writes Packages
                packageSelection = packageCollection.insertTag("PackageSelection")
                packageSelection.setAttribute("repo_uri", collection.packageSelection.repoURI)
                for item in collection.packageSelection.selectedComponents:
                    packageSelection.insertTag("SelectedComponent").insertData(item)
                for item in collection.packageSelection.selectedPackages:
                    packageSelection.insertTag("SelectedPackage").insertData(item)
                for item in collection.packageSelection.allPackages:
                    packageSelection.insertTag("Package").insertData(item)

                # Writes Languages
                languageSelection = packageCollection.insertTag("LanguageSelection")
                if collection.languageSelection.defaultLanguage:
                    languageSelection.setAttribute("default_language", collection.languageSelection.defaultLanguage)
                for language in collection.languageSelection.languages:
                    languageSelection.insertTag("Language").insertData(language)

        else:
            package_selection = doc.insertTag("PackageSelection")
            package_selection.setAttribute("repo_uri", self.repo_uri)

            # Insert components if any
            for item in self.selected_components:
                package_selection.insertTag("SelectedComponent").insertData(item)

            for item in self.selected_packages:
                package_selection.insertTag("SelectedPackage").insertData(item)

            for item in self.all_packages:
                package_selection.insertTag("Package").insertData(item)

        if self.default_language:
            # Set the default language
            langs = doc.insertTag("LanguageSelection")
            langs.setAttribute("default_language", self.default_language)

            # Insert other supported languages if any
            for item in self.selected_languages:
                langs.insertTag("Language").insertData(item)

        # Write the file
        if not filename:
            filename = self.filename
        f = file(filename, "w")
        f.write(doc.toPrettyString())
        f.close()
Exemplo n.º 36
0
 def _get_doc(self):
     repos_file = os.path.join(ctx.config.info_dir(), ctx.const.repos)
     if not os.path.exists(repos_file):
         return piksemel.newDocument("REPOS")
     return piksemel.parse(repos_file)
Exemplo n.º 37
0
#!/usr/bin/env python3

import piksemel as iks

doc_xml = '<lala b="" c="42"/>'

doc = iks.newDocument("lala")
doc.setAttribute("a", "lala")
doc.setAttribute("b", "nanuk")
doc.setAttribute("b", "")
doc.setAttribute("a", None)
doc.setAttribute("c", "42")

assert (doc.toString() == doc_xml)
Exemplo n.º 38
0
	def __init__(self, parent = None):
        	QtGui.QWidget.__init__(self, parent)
		self.setGeometry(QtCore.QRect(0,30,519,563))
		self.resize(519,616)
		
		self.label = QtGui.QLabel(self)
		self.label.setGeometry(QtCore.QRect(150,40,201,41))
		self.label.setObjectName("label")
		self.power_check = QtGui.QCheckBox(self)
		self.power_check.setGeometry(QtCore.QRect(300,350,59,23))
		self.power_check.setObjectName("power_check")
		self.pnp_check = QtGui.QCheckBox(self)
		self.pnp_check.setGeometry(QtCore.QRect(170,350,46,23))
		self.pnp_check.setObjectName("pnp_check")
		self.gruplar_label = QtGui.QLabel(self)
		self.gruplar_label.setGeometry(QtCore.QRect(116,259,44,22))
		
		font = QtGui.QFont()
		font.setFamily("Sans Serif")
		font.setWeight(50)
		font.setBold(False)
		self.gruplar_label.setFont(font)
		self.gruplar_label.setObjectName("gruplar_label")
		self.video_check = QtGui.QCheckBox(self)
		self.video_check.setGeometry(QtCore.QRect(299,320,56,23))
		self.video_check.setObjectName("video_check")
		self.sifre_line = QtGui.QLineEdit(self)
		self.sifre_line.setGeometry(QtCore.QRect(170,200,201,24))
		self.sifre_line.setObjectName("sifre_line")
		self.kullaniciekle_buton = QtGui.QPushButton(self)
		self.kullaniciekle_buton.setGeometry(QtCore.QRect(170,420,131,28))
		self.kullaniciekle_buton.setObjectName("kullaniciekle_buton")
		self.wheel_check = QtGui.QCheckBox(self)
		self.wheel_check.setGeometry(QtCore.QRect(300,380,80,23))
		self.wheel_check.setObjectName("wheel_check")
		self.dialout_check = QtGui.QCheckBox(self)
		self.dialout_check.setGeometry(QtCore.QRect(170,290,68,23))
		self.dialout_check.setObjectName("dialout_check")
		self.kullaniciadi_label = QtGui.QLabel(self)
		self.kullaniciadi_label.setGeometry(QtCore.QRect(89,141,71,18))
		
		font = QtGui.QFont()
		font.setFamily("Sans Serif")
		font.setWeight(50)
		font.setBold(False)
		self.kullaniciadi_label.setFont(font)
		self.kullaniciadi_label.setObjectName("kullaniciadi_label")
		self.pnpadmin_check = QtGui.QCheckBox(self)
		self.pnpadmin_check.setGeometry(QtCore.QRect(170,380,84,23))
		self.pnpadmin_check.setObjectName("pnpadmin_check")
		self.sifre_label = QtGui.QLabel(self)
		self.sifre_label.setGeometry(QtCore.QRect(132,197,28,22))
		font = QtGui.QFont()
		font.setFamily("Sans Serif")
		font.setWeight(50)
		font.setBold(False)
		self.sifre_label.setFont(font)
		self.sifre_label.setObjectName("sifre_label")
		self.removable_check = QtGui.QCheckBox(self)
		self.removable_check.setGeometry(QtCore.QRect(299,291,87,23))
		self.removable_check.setObjectName("removable_check")
		self.users_check = QtGui.QCheckBox(self)
		self.users_check.setGeometry(QtCore.QRect(299,262,56,23))
		self.users_check.setObjectName("users_check")
		self.kullanicigercekadi_line = QtGui.QLineEdit(self)
		self.kullanicigercekadi_line.setGeometry(QtCore.QRect(170,170,201,24))
		self.kullanicigercekadi_line.setObjectName("kullanicigercekadi_line")
		self.sifre2_line = QtGui.QLineEdit(self)
		self.sifre2_line.setGeometry(QtCore.QRect(169,229,201,24))
		self.sifre2_line.setObjectName("sifre2_line")
		self.kullanicigercekadi_label = QtGui.QLabel(self)
		self.kullanicigercekadi_label.setGeometry(QtCore.QRect(47,166,113,22))
		font = QtGui.QFont()
		font.setFamily("Sans Serif")
		font.setWeight(50)
		font.setBold(False)
		self.kullanicigercekadi_label.setFont(font)
		self.kullanicigercekadi_label.setObjectName("kullanicigercekadi_label")
		self.sifre2_label = QtGui.QLabel(self)
		self.sifre2_label.setGeometry(QtCore.QRect(80,228,80,22))
		font = QtGui.QFont()
		font.setFamily("Sans Serif")
		font.setWeight(50)
		font.setBold(False)
		self.sifre2_label.setFont(font)
		self.sifre2_label.setObjectName("sifre2_label")
		self.kullanicieklendi_buton = QtGui.QLabel(self)
		self.kullanicieklendi_buton.setGeometry(QtCore.QRect(310,430,201,18))
		self.kullanicieklendi_buton.setObjectName("kullanicieklendi_buton")
		self.kullanicieklendi_buton.hide()	
		self.kullaniciadi_line = QtGui.QLineEdit(self)
		
		self.kullaniciadi_line.setGeometry(QtCore.QRect(170,140,201,24))
		self.kullaniciadi_line.setObjectName("kullaniciadi_line")
		self.audio_check = QtGui.QCheckBox(self)
		self.audio_check.setGeometry(QtCore.QRect(169,259,56,23))
		self.audio_check.setObjectName("audio_check")
		self.disk_check = QtGui.QCheckBox(self)
		self.disk_check.setGeometry(QtCore.QRect(170,320,48,23))
		self.disk_check.setObjectName("disk_check")
		self.devamet_buton = QtGui.QPushButton(self)
		self.devamet_buton.setGeometry(QtCore.QRect(390,500,75,28))
		self.devamet_buton.setObjectName("devamet_buton")
		self.baskakullaniciekle_buton = QtGui.QPushButton(self)
		self.baskakullaniciekle_buton.setGeometry(QtCore.QRect(170,460,131,28))
		self.baskakullaniciekle_buton.setObjectName("baskakullaniciekle_buton")
		self.baskakullaniciekle_buton.hide()	
		#MainWindow.setCentralWidget(self.centralwidget)
		
		self.connect(self.kullaniciekle_buton, QtCore.SIGNAL("clicked()"), self.kullanici_ekle)
		self.connect(self.devamet_buton, QtCore.SIGNAL("clicked()"), self.devamet)
		self.connect(self.baskakullaniciekle_buton, QtCore.SIGNAL("clicked()"), self.baskakullaniciekle)
		
		
		
		
		
		self.label.setText(QtGui.QApplication.translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
	"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
	"p, li { white-space: pre-wrap; }\n"
	"</style></head><body style=\" font-family:\'Sans Serif\'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
	"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:14pt;\">KULLANICI AYARLARI</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
		self.power_check.setText(QtGui.QApplication.translate("MainWindow", "Power", None, QtGui.QApplication.UnicodeUTF8))
		self.pnp_check.setText(QtGui.QApplication.translate("MainWindow", "Pnp", None, QtGui.QApplication.UnicodeUTF8))
		self.gruplar_label.setText(QtGui.QApplication.translate("MainWindow", "Gruplar:", None, QtGui.QApplication.UnicodeUTF8))
		self.video_check.setText(QtGui.QApplication.translate("MainWindow", "Video", None, QtGui.QApplication.UnicodeUTF8))
		self.kullaniciekle_buton.setText(QtGui.QApplication.translate("MainWindow", "EKLE", None, QtGui.QApplication.UnicodeUTF8))
		self.wheel_check.setText(QtGui.QApplication.translate("MainWindow", "Wheel", None, QtGui.QApplication.UnicodeUTF8))
		self.dialout_check.setText(QtGui.QApplication.translate("MainWindow", "Dial Out", None, QtGui.QApplication.UnicodeUTF8))
		self.kullaniciadi_label.setText(QtGui.QApplication.translate("MainWindow", "Kullanici adi:", None, QtGui.QApplication.UnicodeUTF8))
		self.pnpadmin_check.setText(QtGui.QApplication.translate("MainWindow", "Pnp Admin", None, QtGui.QApplication.UnicodeUTF8))
		self.sifre_label.setText(QtGui.QApplication.translate("MainWindow", "Sifre:", None, QtGui.QApplication.UnicodeUTF8))
		self.removable_check.setText(QtGui.QApplication.translate("MainWindow", "Removable", None, QtGui.QApplication.UnicodeUTF8))
		self.users_check.setText(QtGui.QApplication.translate("MainWindow", "Users", None, QtGui.QApplication.UnicodeUTF8))
		self.kullanicigercekadi_label.setText(QtGui.QApplication.translate("MainWindow", "Kullanici Gercek Adi:", None, QtGui.QApplication.UnicodeUTF8))
		self.sifre2_label.setText(QtGui.QApplication.translate("MainWindow", "Sifre(yeniden):", None, QtGui.QApplication.UnicodeUTF8))
		self.kullanicieklendi_buton.setText(QtGui.QApplication.translate("MainWindow", "Kullanici eklendi!", None, QtGui.QApplication.UnicodeUTF8))
		self.audio_check.setText(QtGui.QApplication.translate("MainWindow", "Audio", None, QtGui.QApplication.UnicodeUTF8))
		self.disk_check.setText(QtGui.QApplication.translate("MainWindow", "Disk", None, QtGui.QApplication.UnicodeUTF8))
		self.devamet_buton.setText(QtGui.QApplication.translate("MainWindow", "Devam Et", None, QtGui.QApplication.UnicodeUTF8))
		self.baskakullaniciekle_buton.setText(QtGui.QApplication.translate("MainWindow", "Baska Kullanici Ekle", None, QtGui.QApplication.UnicodeUTF8))
		
		
		
		
		
		self.userrecords_tag = piksemel.newDocument("yali")
		self.userrecords_tag.insertData("\n\t")
		self.users_tag = self.userrecords_tag.insertTag("users")
Exemplo n.º 39
0
    def generate(self):
        """Generates XML File with the attributes of the object."""

        # Put the constant header
        xmlHeader = '''<?xml version="1.0" encoding="utf-8"?>
'''
        doc = piksemel.newDocument("yali")
        doc.setAttribute("xmlns:xsi",
                         "http://www.w3.org/2001/XMLSchema-instance")
        doc.setAttribute("xsi:noNamespaceSchemaLocation", "yalisema.xsd")

        # Set language and variant information
        doc.insertTag("language").insertData(self.language)
        if self.variant:
            doc.insertTag("variant").insertData(self.variant)

        # Root password: shadowed or not...
        if self.root_shadowed:
            srp = doc.insertTag("root_password")
            srp.insertData(self.root_password)
            srp.setAttribute("shadowed", "yes")
        else:
            doc.insertTag("root_password").insertData(self.root_password)

        # Timezone and hostname
        doc.insertTag("timezone").insertData(self.timezone)
        doc.insertTag("hostname").insertData(self.hostname)

        # ------ User Stuff ---------------
        # Note that if statement below can be removed if </users> tag is desired.
        if self.users:
            usersTag = doc.insertTag("users")
            for theuser in self.users:
                newuser = usersTag.insertTag("user")
                # If it is autologin, then set set an attribute to it.
                if theuser.autologin:
                    newuser.setAttribute("autologin", "yes")

                # username and realName
                newuser.insertTag("username").insertData(theuser.username)
                newuser.insertTag("realname").insertData(theuser.realName)

                # Password: Normal or shadowed
                if theuser.shadowed:
                    sp = newuser.insertTag("password")
                    sp.insertData(theuser.shadowedPassword)
                    sp.setAttribute("shadowed", "yes")
                else:
                    newuser.insertTag("password").insertData(
                        theuser.normalPassword)

                # Groups for user.
                newuser.insertTag("groups").insertData(",".join(
                    theuser.groups))
        # ----- USER STUFF FINISHED --------

        # Repo and partitioning settings
        doc.insertTag("reponame").insertData(self.reponame)
        doc.insertTag("repoaddr").insertData(self.repoaddr)

        pt = doc.insertTag("partitioning")
        pt.insertData(self.disk)
        pt.setAttribute("partitioning_type", self.partitioning_type)

        # ------ ALL FINISHED -------------

        # Now try to write the XML File.
        try:
            f = open(self.filename, "w")
            f.write(xmlHeader + doc.toPrettyString())
            f.close()
            return {'status': True, 'filename': self.filename}
        except:
            # print _("Could not write to %s") % self.filename
            return {'status': False, 'filename': self.filename}
Exemplo n.º 40
0
    def save(self, filename=None):
        # Save the data into filename as pardusman project file
        doc = piksemel.newDocument("PardusmanProject")

        doc.setAttribute("type", self.type)
        doc.setAttribute("compression", str(self.squashfs_comp_type))

        if self.title:
            doc.insertTag("Title").insertData(self.title)
        if self.work_dir:
            doc.insertTag("WorkDir").insertData(self.work_dir)
        if self.release_files:
            doc.insertTag("ReleaseFiles").insertData(self.release_files)
        if self.plugin_package:
            doc.insertTag("PluginPackage").insertData(self.plugin_package)
        if self.extra_params:
            doc.insertTag("ExtraParameters").insertData(self.extra_params)

        if self.package_collections:
            collections = doc.insertTag("PackageCollections")
            for collection in self.package_collections:
                packageCollection = collections.insertTag("PackageCollection")
                # Writes if collection is default
                if collection.default:
                    packageCollection.setAttribute("default", collection.default)

                # Writes Collection identifiers
                packageCollection.insertTag("Id").insertData(collection._id)
                packageCollection.insertTag("Icon").insertData(collection.icon)

                # Writes Translations
                translations = packageCollection.insertTag("Translations")
                for key, item in collection.translations.items():
                    translation = translations.insertTag("Translation")
                    translation.setAttribute("language", key)
                    translation.insertTag("Title").insertData(item[0])
                    translation.insertTag("Description").insertData(item[1])

                # Writes Packages
                packageSelection = packageCollection.insertTag("PackageSelection")
                # FIXME: ilker manap, self.repo_uri almasi gerek.
                packageSelection.setAttribute("repo_uri", self.repo_uri)
                for item in collection.packages.selectedComponents:
                    packageSelection.insertTag("SelectedComponent").insertData(item)
                for item in collection.packages.selectedPackages:
                    packageSelection.insertTag("SelectedPackage").insertData(item)
                for item in collection.packages.allPackages:
                    packageSelection.insertTag("Package").insertData(item)

        else:
            self.selected_components.sort()
            self.selected_packages.sort()
            self.all_packages.sort()

            package_selection = doc.insertTag("PackageSelection")
            package_selection.setAttribute("repo_uri", self.repo_uri)

            # Insert components if any
            for item in self.selected_components:
                package_selection.insertTag("SelectedComponent").insertData(item)

            for item in self.selected_packages:
                package_selection.insertTag("SelectedPackage").insertData(item)

            for item in self.all_packages:
                package_selection.insertTag("Package").insertData(item)

        if self.all_install_image_packages:
            self.selected_install_image_components.sort()
            self.selected_install_image_packages.sort()
            self.all_install_image_packages.sort()

            package_selection = doc.insertTag("InstallImagePackages")

            # Insert components if any
            for item in self.selected_install_image_components:
                package_selection.insertTag("SelectedComponent").insertData(item)

            for item in self.selected_install_image_packages:
                package_selection.insertTag("SelectedPackage").insertData(item)

            for item in self.all_install_image_packages:
                package_selection.insertTag("Package").insertData(item)

        if self.default_language:
            # Set the default language
            langs = doc.insertTag("LanguageSelection")
            langs.setAttribute("default_language", self.default_language)

            # Insert other supported languages if any
            for item in self.selected_languages:
                langs.insertTag("Language").insertData(item)

        # Write the file
        if not filename:
            filename = self.filename
        f = file(filename, "w")
        f.write(doc.toPrettyString())
        f.close()
Exemplo n.º 41
0
def saveDeviceInfo(card):
    if not os.path.exists(zorgConfigDir):
        os.mkdir(zorgConfigDir, 0755)

    configFile = os.path.join(zorgConfigDir, zorgConfig)

    try:
        doc = piksemel.parse(configFile)
    except OSError:
        doc = piksemel.newDocument("ZORG")

    info = card.getDict()

    for tag in doc.tags("Card"):
        if tag.getAttribute("busId") == info["bus-id"]:
            tag.hide()
            break

    cardTag = doc.insertTag("Card")
    cardTag.setAttribute("busId", info["bus-id"])

    addTag(cardTag, "VendorId", card.vendor_id)
    addTag(cardTag, "ProductId", card.product_id)

    probeResult = cardTag.insertTag("ProbeResult")
    for key, value in card.probe_result.items():
        t = probeResult.insertTag("Value")
        t.setAttribute("key", key)
        if value:
            t.insertData(value)

    config = cardTag.insertTag("ActiveConfig")

    driver = config.insertTag("Driver")
    driver.setAttribute("package", card.package)
    driver.insertData(card.driver)

    addTag(config, "Depth", card.depth)
    addTag(config, "DesktopSetup", card.desktop_setup)

    def addMonitor(output, tagName):
        mon = card.monitors[output]
        monitor = config.insertTag(tagName)
        monitor.insertTag("Vendor").insertData(mon.vendor)
        monitor.insertTag("Model").insertData(mon.model)
        monitor.insertTag("HorizSync").insertData(mon.hsync)
        monitor.insertTag("VertRefresh").insertData(mon.vref)

    outName = card.active_outputs[0]
    outMode = card.modes.get(outName)
    output = config.insertTag("Output")
    if outMode:
        output.setAttribute("mode", outMode)
    output.insertData(outName)

    if card.monitors.has_key(outName):
        addMonitor(outName, "Monitor")

    if card.desktop_setup != "single":
        outName = card.active_outputs[1]
        outMode = card.modes.get(outName)
        output = config.insertTag("SecondOutput")
        if outMode:
            output.setAttribute("mode", outMode)
        output.insertData(outName)

        if card.monitors.has_key(outName):
            addMonitor(outName, "SecondMonitor")

    f = file(configFile, "w")
    f.write(doc.toPrettyString().replace("\n\n", ""))
    f.close()
Exemplo n.º 42
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.setGeometry(QtCore.QRect(0, 30, 519, 563))
        self.resize(519, 616)

        self.label = QtGui.QLabel(self)
        self.label.setGeometry(QtCore.QRect(150, 40, 201, 41))
        self.label.setObjectName("label")
        self.power_check = QtGui.QCheckBox(self)
        self.power_check.setGeometry(QtCore.QRect(300, 350, 59, 23))
        self.power_check.setObjectName("power_check")
        self.pnp_check = QtGui.QCheckBox(self)
        self.pnp_check.setGeometry(QtCore.QRect(170, 350, 46, 23))
        self.pnp_check.setObjectName("pnp_check")
        self.gruplar_label = QtGui.QLabel(self)
        self.gruplar_label.setGeometry(QtCore.QRect(116, 259, 44, 22))

        font = QtGui.QFont()
        font.setFamily("Sans Serif")
        font.setWeight(50)
        font.setBold(False)
        self.gruplar_label.setFont(font)
        self.gruplar_label.setObjectName("gruplar_label")
        self.video_check = QtGui.QCheckBox(self)
        self.video_check.setGeometry(QtCore.QRect(299, 320, 56, 23))
        self.video_check.setObjectName("video_check")
        self.sifre_line = QtGui.QLineEdit(self)
        self.sifre_line.setGeometry(QtCore.QRect(170, 200, 201, 24))
        self.sifre_line.setObjectName("sifre_line")
        self.kullaniciekle_buton = QtGui.QPushButton(self)
        self.kullaniciekle_buton.setGeometry(QtCore.QRect(170, 420, 131, 28))
        self.kullaniciekle_buton.setObjectName("kullaniciekle_buton")
        self.wheel_check = QtGui.QCheckBox(self)
        self.wheel_check.setGeometry(QtCore.QRect(300, 380, 80, 23))
        self.wheel_check.setObjectName("wheel_check")
        self.dialout_check = QtGui.QCheckBox(self)
        self.dialout_check.setGeometry(QtCore.QRect(170, 290, 68, 23))
        self.dialout_check.setObjectName("dialout_check")
        self.kullaniciadi_label = QtGui.QLabel(self)
        self.kullaniciadi_label.setGeometry(QtCore.QRect(89, 141, 71, 18))

        font = QtGui.QFont()
        font.setFamily("Sans Serif")
        font.setWeight(50)
        font.setBold(False)
        self.kullaniciadi_label.setFont(font)
        self.kullaniciadi_label.setObjectName("kullaniciadi_label")
        self.pnpadmin_check = QtGui.QCheckBox(self)
        self.pnpadmin_check.setGeometry(QtCore.QRect(170, 380, 84, 23))
        self.pnpadmin_check.setObjectName("pnpadmin_check")
        self.sifre_label = QtGui.QLabel(self)
        self.sifre_label.setGeometry(QtCore.QRect(132, 197, 28, 22))
        font = QtGui.QFont()
        font.setFamily("Sans Serif")
        font.setWeight(50)
        font.setBold(False)
        self.sifre_label.setFont(font)
        self.sifre_label.setObjectName("sifre_label")
        self.removable_check = QtGui.QCheckBox(self)
        self.removable_check.setGeometry(QtCore.QRect(299, 291, 87, 23))
        self.removable_check.setObjectName("removable_check")
        self.users_check = QtGui.QCheckBox(self)
        self.users_check.setGeometry(QtCore.QRect(299, 262, 56, 23))
        self.users_check.setObjectName("users_check")
        self.kullanicigercekadi_line = QtGui.QLineEdit(self)
        self.kullanicigercekadi_line.setGeometry(
            QtCore.QRect(170, 170, 201, 24))
        self.kullanicigercekadi_line.setObjectName("kullanicigercekadi_line")
        self.sifre2_line = QtGui.QLineEdit(self)
        self.sifre2_line.setGeometry(QtCore.QRect(169, 229, 201, 24))
        self.sifre2_line.setObjectName("sifre2_line")
        self.kullanicigercekadi_label = QtGui.QLabel(self)
        self.kullanicigercekadi_label.setGeometry(
            QtCore.QRect(47, 166, 113, 22))
        font = QtGui.QFont()
        font.setFamily("Sans Serif")
        font.setWeight(50)
        font.setBold(False)
        self.kullanicigercekadi_label.setFont(font)
        self.kullanicigercekadi_label.setObjectName("kullanicigercekadi_label")
        self.sifre2_label = QtGui.QLabel(self)
        self.sifre2_label.setGeometry(QtCore.QRect(80, 228, 80, 22))
        font = QtGui.QFont()
        font.setFamily("Sans Serif")
        font.setWeight(50)
        font.setBold(False)
        self.sifre2_label.setFont(font)
        self.sifre2_label.setObjectName("sifre2_label")
        self.kullanicieklendi_buton = QtGui.QLabel(self)
        self.kullanicieklendi_buton.setGeometry(QtCore.QRect(
            310, 430, 201, 18))
        self.kullanicieklendi_buton.setObjectName("kullanicieklendi_buton")
        self.kullanicieklendi_buton.hide()
        self.kullaniciadi_line = QtGui.QLineEdit(self)

        self.kullaniciadi_line.setGeometry(QtCore.QRect(170, 140, 201, 24))
        self.kullaniciadi_line.setObjectName("kullaniciadi_line")
        self.audio_check = QtGui.QCheckBox(self)
        self.audio_check.setGeometry(QtCore.QRect(169, 259, 56, 23))
        self.audio_check.setObjectName("audio_check")
        self.disk_check = QtGui.QCheckBox(self)
        self.disk_check.setGeometry(QtCore.QRect(170, 320, 48, 23))
        self.disk_check.setObjectName("disk_check")
        self.devamet_buton = QtGui.QPushButton(self)
        self.devamet_buton.setGeometry(QtCore.QRect(390, 500, 75, 28))
        self.devamet_buton.setObjectName("devamet_buton")
        self.baskakullaniciekle_buton = QtGui.QPushButton(self)
        self.baskakullaniciekle_buton.setGeometry(
            QtCore.QRect(170, 460, 131, 28))
        self.baskakullaniciekle_buton.setObjectName("baskakullaniciekle_buton")
        self.baskakullaniciekle_buton.hide()
        #MainWindow.setCentralWidget(self.centralwidget)

        self.connect(self.kullaniciekle_buton, QtCore.SIGNAL("clicked()"),
                     self.kullanici_ekle)
        self.connect(self.devamet_buton, QtCore.SIGNAL("clicked()"),
                     self.devamet)
        self.connect(self.baskakullaniciekle_buton, QtCore.SIGNAL("clicked()"),
                     self.baskakullaniciekle)

        self.label.setText(
            QtGui.QApplication.translate(
                "MainWindow",
                "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
                "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
                "p, li { white-space: pre-wrap; }\n"
                "</style></head><body style=\" font-family:\'Sans Serif\'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
                "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:14pt;\">KULLANICI AYARLARI</span></p></body></html>",
                None, QtGui.QApplication.UnicodeUTF8))
        self.power_check.setText(
            QtGui.QApplication.translate("MainWindow", "Power", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.pnp_check.setText(
            QtGui.QApplication.translate("MainWindow", "Pnp", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.gruplar_label.setText(
            QtGui.QApplication.translate("MainWindow", "Gruplar:", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.video_check.setText(
            QtGui.QApplication.translate("MainWindow", "Video", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.kullaniciekle_buton.setText(
            QtGui.QApplication.translate("MainWindow", "EKLE", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.wheel_check.setText(
            QtGui.QApplication.translate("MainWindow", "Wheel", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.dialout_check.setText(
            QtGui.QApplication.translate("MainWindow", "Dial Out", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.kullaniciadi_label.setText(
            QtGui.QApplication.translate("MainWindow", "Kullanici adi:", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.pnpadmin_check.setText(
            QtGui.QApplication.translate("MainWindow", "Pnp Admin", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.sifre_label.setText(
            QtGui.QApplication.translate("MainWindow", "Sifre:", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.removable_check.setText(
            QtGui.QApplication.translate("MainWindow", "Removable", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.users_check.setText(
            QtGui.QApplication.translate("MainWindow", "Users", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.kullanicigercekadi_label.setText(
            QtGui.QApplication.translate("MainWindow", "Kullanici Gercek Adi:",
                                         None, QtGui.QApplication.UnicodeUTF8))
        self.sifre2_label.setText(
            QtGui.QApplication.translate("MainWindow", "Sifre(yeniden):", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.kullanicieklendi_buton.setText(
            QtGui.QApplication.translate("MainWindow", "Kullanici eklendi!",
                                         None, QtGui.QApplication.UnicodeUTF8))
        self.audio_check.setText(
            QtGui.QApplication.translate("MainWindow", "Audio", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.disk_check.setText(
            QtGui.QApplication.translate("MainWindow", "Disk", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.devamet_buton.setText(
            QtGui.QApplication.translate("MainWindow", "Devam Et", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.baskakullaniciekle_buton.setText(
            QtGui.QApplication.translate("MainWindow", "Baska Kullanici Ekle",
                                         None, QtGui.QApplication.UnicodeUTF8))

        self.userrecords_tag = piksemel.newDocument("yali")
        self.userrecords_tag.insertData("\n\t")
        self.users_tag = self.userrecords_tag.insertTag("users")
Exemplo n.º 43
0
def newNode(node, tag):
    return iks.newDocument(tag)
Exemplo n.º 44
0
def newNode(node, tag):
    return iks.newDocument(tag)
Exemplo n.º 45
0
    def save(self, filename=None):
        # Save the data into filename as pardusman project file
        doc = piksemel.newDocument("PardusmanProject")

        doc.setAttribute("type", self.type)
        doc.setAttribute("compression", str(self.squashfs_comp_type))

        if self.title:
            doc.insertTag("Title").insertData(self.title)
        if self.work_dir:
            doc.insertTag("WorkDir").insertData(self.work_dir)
        if self.release_files:
            doc.insertTag("ReleaseFiles").insertData(self.release_files)
        if self.plugin_package:
            doc.insertTag("PluginPackage").insertData(self.plugin_package)
        if self.extra_params:
            doc.insertTag("ExtraParameters").insertData(self.extra_params)

        if self.package_collections:
            collections = doc.insertTag("PackageCollections")
            for collection in self.package_collections:
                packageCollection = collections.insertTag("PackageCollection")
                # Writes if collection is default
                if collection.default:
                    packageCollection.setAttribute("default",
                                                   collection.default)

                # Writes Collection identifiers
                packageCollection.insertTag("Id").insertData(collection._id)
                packageCollection.insertTag("Icon").insertData(collection.icon)

                # Writes Translations
                translations = packageCollection.insertTag("Translations")
                for key, item in collection.translations.items():
                    translation = translations.insertTag("Translation")
                    translation.setAttribute("language", key)
                    translation.insertTag("Title").insertData(item[0])
                    translation.insertTag("Description").insertData(item[1])

                # Writes Packages
                packageSelection = packageCollection.insertTag(
                    "PackageSelection")
                packageSelection.setAttribute("repo_uri",
                                              collection.packages.repoURI)
                for item in collection.packages.selectedComponents:
                    packageSelection.insertTag("SelectedComponent").insertData(
                        item)
                for item in collection.packages.selectedPackages:
                    packageSelection.insertTag("SelectedPackage").insertData(
                        item)
                for item in collection.packages.allPackages:
                    packageSelection.insertTag("Package").insertData(item)

        else:
            self.selected_components.sort()
            self.selected_packages.sort()
            self.all_packages.sort()

            package_selection = doc.insertTag("PackageSelection")
            package_selection.setAttribute("repo_uri", self.repo_uri)

            # Insert components if any
            for item in self.selected_components:
                package_selection.insertTag("SelectedComponent").insertData(
                    item)

            for item in self.selected_packages:
                package_selection.insertTag("SelectedPackage").insertData(item)

            for item in self.all_packages:
                package_selection.insertTag("Package").insertData(item)

        if self.all_install_image_packages:
            self.selected_install_image_components.sort()
            self.selected_install_image_packages.sort()
            self.all_install_image_packages.sort()

            package_selection = doc.insertTag("InstallImagePackages")

            # Insert components if any
            for item in self.selected_install_image_components:
                package_selection.insertTag("SelectedComponent").insertData(
                    item)

            for item in self.selected_install_image_packages:
                package_selection.insertTag("SelectedPackage").insertData(item)

            for item in self.all_install_image_packages:
                package_selection.insertTag("Package").insertData(item)

        if self.default_language:
            # Set the default language
            langs = doc.insertTag("LanguageSelection")
            langs.setAttribute("default_language", self.default_language)

            # Insert other supported languages if any
            for item in self.selected_languages:
                langs.insertTag("Language").insertData(item)

        # Write the file
        if not filename:
            filename = self.filename
        f = file(filename, "w")
        f.write(doc.toPrettyString())
        f.close()
Exemplo n.º 46
0
    print "Error!"
while x:
    if x.type() == iks.CDATA:
        print x.data()
    else:
        print x.name()
    x = x.next()

# test attributes
doc = iks.parseString("<a><blah hede='lala'/></a>")
blah = doc.getTag("blah")
print blah.getAttribute("hede"), blah.getAttribute("hodo")

# test append node
doc1 = iks.parseString("<a>blah</a>")
doc2 = iks.newDocument("b")
doc2.appendData("bold text")
doc1.appendNode(doc2)
del doc2
print doc1.toString()

# test iteration
doc = iks.parse(sys.argv[1])
for a in doc:
    a.toString()
    if a.type() == iks.TAG:
        a.toPrettyString()
doc.toString()
doc.toPrettyString()

# test tag iteration
Exemplo n.º 47
0
 def _get_doc(self):
     repos_file = os.path.join(ctx.config.info_dir(), ctx.const.repos)
     if not os.path.exists(repos_file):
         return piksemel.newDocument("REPOS")
     return piksemel.parse(repos_file)
Exemplo n.º 48
0
 def newDocument(self):
     """clear DOM"""
     self.doc = iks.newDocument(self.rootTag)
Exemplo n.º 49
0
    def save(self, filename=None):
        # Save the data into filename as pardusman project file
        doc = piksemel.newDocument("PardusmanProject")

        doc.setAttribute("type", self.type)
        doc.setAttribute("media", str(self.media))

	selected_components = []

        for comp in self.selected_components:
            selected_components.append(comp.replace('-','.'))

        if self.title:
            doc.insertTag("Title").insertData(self.title)
        if self.work_dir:
            doc.insertTag("WorkDir").insertData(self.work_dir)
        if self.release_files:
            doc.insertTag("ReleaseFiles").insertData(self.release_files)
        if self.plugin_package:
            doc.insertTag("PluginPackage").insertData(self.plugin_package)
        if self.extra_params:
            doc.insertTag("ExtraParameters").insertData(self.extra_params)

        if self.username:
            doc.insertTag("Username").insertData(self.username)

        if self.password:
            doc.insertTag("Password").insertData(self.password)

        if self.wallpaper:
            doc.insertTag("Wallpaper").insertData(self.wallpaper)
        if self.user_contents:
            doc.insertTag("UserContents").insertData(self.user_contents)
        if self.hostname:
            doc.insertTag("Hostname").insertData(self.hostname)

        if self.repo:
            package_selection = doc.insertTag("PackageSelection")
            package_selection.setAttribute("repo", self.repo)

            # Insert components if any
            for item in selected_components:
                package_selection.insertTag("SelectedComponent").insertData(item)

            for item in self.selected_packages:
                package_selection.insertTag("SelectedPackage").insertData(item)

            for item in self.all_packages:
                package_selection.insertTag("Package").insertData(item)

        if self.default_language:
            # Set the default language
            langs = doc.insertTag("LanguageSelection")
            langs.setAttribute("default_language", self.default_language)

            # Insert other supported languages if any
            for item in self.selected_languages:
                langs.insertTag("Language").insertData(item)

        # Write the file
        if not filename:
            filename = self.filename
        f = file(filename, "w")
        f.write(doc.toPrettyString())
        f.close()
Exemplo n.º 50
0
#!/usr/bin/python

import piksemel

doc = piksemel.newDocument("lala")

try:
    doc.appendTag("lala")
except piksemel.NotTag:
    pass

try:
    doc.appendData("lala")
except piksemel.NotTag:
    pass

try:
    doc.prependTag("lala")
except piksemel.NotTag:
    pass

try:
    doc.prependData("lala")
except piksemel.NotTag:
    pass

Exemplo n.º 51
0
    def generate(self):
        """Generates XML File with the attributes of the object."""
        
        # Put the constant header
        xmlHeader =  '''<?xml version="1.0" encoding="utf-8"?>
'''
        doc = piksemel.newDocument("yali")
        doc.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance")
        doc.setAttribute("xsi:noNamespaceSchemaLocation","yalisema.xsd")
        
        # Set language and variant information
        doc.insertTag("language").insertData(self.language)
        if self.variant:
            doc.insertTag("variant").insertData(self.variant)
        
        # Root password: shadowed or not...
        if self.root_shadowed:
            srp = doc.insertTag("root_password")
            srp.insertData(self.root_password)
            srp.setAttribute("shadowed", "yes")
        else:                    
            doc.insertTag("root_password").insertData(self.root_password)
        
        # Timezone and hostname
        doc.insertTag("timezone").insertData(self.timezone)
        doc.insertTag("hostname").insertData(self.hostname)
                
        # ------ User Stuff ---------------
        # Note that if statement below can be removed if </users> tag is desired.
        if self.users:
            usersTag = doc.insertTag("users")
            for theuser in self.users:
                newuser = usersTag.insertTag("user")
                # If it is autologin, then set set an attribute to it.
                if theuser.autologin:
                    newuser.setAttribute("autologin","yes")
                
                # username and realName
                newuser.insertTag("username").insertData(theuser.username)
                newuser.insertTag("realname").insertData(theuser.realName)
            
                # Password: Normal or shadowed
                if theuser.shadowed:
                    sp = newuser.insertTag("password")
                    sp.insertData(theuser.shadowedPassword)
                    sp.setAttribute("shadowed", "yes")
                else:        
                    newuser.insertTag("password").insertData(theuser.normalPassword)
                
                # Groups for user.
                newuser.insertTag("groups").insertData(",".join(theuser.groups))      
        # ----- USER STUFF FINISHED --------
        
        # Repo and partitioning settings
        doc.insertTag("reponame").insertData(self.reponame)
        doc.insertTag("repoaddr").insertData(self.repoaddr)
        
        pt = doc.insertTag("partitioning")
        pt.insertData(self.disk)
        pt.setAttribute("partitioning_type", self.partitioning_type)
        
        # ------ ALL FINISHED -------------
        
        # Now try to write the XML File.        
        try:
            f = open(self.filename, "w")
            f.write(xmlHeader+doc.toPrettyString())
            f.close()
            return {'status'    : True,
                    'filename'  : self.filename
                    }
        except:
            # print _("Could not write to %s") % self.filename
            return {'status'    : False,
                    'filename'  : self.filename
                    }