Пример #1
0
    def commit(self):
        import yali4.gui.context as ctx

        attempt = 1
        maxTries = 5
        keepTrying = True

        while keepTrying and (attempt <= maxTries):
            try:
                self._disk.commit()
                keepTrying = False
                sysutils.run("sync")
            except Exception, msg:
                attempt += 1
Пример #2
0
    def commit(self):
        import yali4.gui.context as ctx

        attempt = 1
        maxTries = 5
        keepTrying = True

        while keepTrying and (attempt <= maxTries):
            try:
                self._disk.commit()
                keepTrying = False
                sysutils.run("sync")
            except Exception, msg:
                attempt += 1
Пример #3
0
 def setLabel(self, partition, label):
     label = self.availableLabel(label)
     cmd_path = requires("dosfslabel")
     cmd = "%s %s %s" % (cmd_path, partition.getPath(), label)
     if not sysutils.run(cmd):
         return False
     return label
Пример #4
0
 def format(self, partition):
     self.preFormat(partition)
     cmd_path = requires("mkfs.vfat")
     cmd = "%s %s" % (cmd_path, partition.getPath())
     res = sysutils.run(cmd)
     if not res:
         raise YaliException, "vfat format failed: %s" % partition.getPath()
Пример #5
0
 def format(self, partition):
     self.preFormat(partition)
     cmd_path = requires("mkfs.vfat")
     cmd = "%s %s" %(cmd_path,partition.getPath())
     res = sysutils.run(cmd)
     if not res:
         raise YaliException, "vfat format failed: %s" % partition.getPath()
Пример #6
0
 def format(self, partition):
     self.preFormat(partition)
     cmd_path = requires("mkfs.xfs")
     cmd = "%s -f %s" %(cmd_path, partition.getPath())
     res = sysutils.run(cmd)
     if not res:
         raise YaliException, "%s format failed: %s" % (self.name(), partition.getPath())
Пример #7
0
 def setLabel(self, partition, label):
     label = self.availableLabel(label)
     cmd_path = requires("xfs_admin")
     cmd = "%s -L %s %s" % (cmd_path, label, partition.getPath())
     if not sysutils.run(cmd):
         return False
     return label
Пример #8
0
 def setLabel(self, partition, label):
     label = self.availableLabel(label)
     cmd_path = requires("xfs_admin")
     cmd = "%s -L %s %s" % (cmd_path, label, partition.getPath())
     if not sysutils.run(cmd):
         return False
     return label
Пример #9
0
 def setLabel(self, partition, label):
     label = self.availableLabel(label)
     cmd_path = requires("dosfslabel")
     cmd = "%s %s %s" % (cmd_path, partition.getPath(), label)
     if not sysutils.run(cmd):
         return False
     return label
Пример #10
0
 def getLabel(self, partition):
     """ Read file system label and return """
     cmd_path = requires("e2label")
     cmd = "%s %s" % (cmd_path, partition.getPath())
     label = sysutils.run(cmd, capture=True)
     if not label:
         return False
     return label.strip()
Пример #11
0
 def tune2fs(self, partition):
     """ Runs tune2fs for given partition """
     cmd_path = requires("tune2fs")
     # Disable mount count and use 6 month interval to fsck'ing disks at boot
     cmd = "%s -c 0 -i 6m %s" % (cmd_path, partition.getPath())
     res = sysutils.run(cmd)
     if not res:
         raise YaliException, "tune2fs tuning failed: %s" % partition.getPath()
Пример #12
0
 def format(self, partition):
     self.preFormat(partition)
     cmd_path = requires("mkfs.xfs")
     cmd = "%s -f %s" % (cmd_path, partition.getPath())
     res = sysutils.run(cmd)
     if not res:
         raise YaliException, "%s format failed: %s" % (self.name(),
                                                        partition.getPath())
Пример #13
0
 def getLabel(self, partition):
     """ Read file system label and return """
     cmd_path = requires("e2label")
     cmd = "%s %s" % (cmd_path, partition.getPath())
     label = sysutils.run(cmd, capture=True)
     if not label:
         return False
     return label.strip()
Пример #14
0
 def setLabel(self, partition, label):
     # FIXME It formats the device twice for setting label
     # Find a better way for it...
     label = self.availableLabel(label)
     cmd_path = requires("mkfs.btrfs")
     cmd = "%s -L %s %s" % (cmd_path, label, partition.getPath())
     if not sysutils.run(cmd):
         return False
     return label
Пример #15
0
 def tune2fs(self, partition):
     """ Runs tune2fs for given partition """
     cmd_path = requires("tune2fs")
     # Disable mount count and use 6 month interval to fsck'ing disks at boot
     cmd = "%s -c 0 -i 6m %s" % (cmd_path, partition.getPath())
     res = sysutils.run(cmd)
     if not res:
         raise YaliException, "tune2fs tuning failed: %s" % partition.getPath(
         )
Пример #16
0
 def setLabel(self, partition, label):
     # FIXME It formats the device twice for setting label
     # Find a better way for it...
     label = self.availableLabel(label)
     cmd_path = requires("mkfs.btrfs")
     cmd = "%s -L %s %s" % (cmd_path, label, partition.getPath())
     if not sysutils.run(cmd):
         return False
     return label
Пример #17
0
 def setLabel(self, partition, label):
     label = self.availableLabel(label)
     cmd_path = requires("e2label")
     cmd = "%s %s %s" % (cmd_path, partition.getPath(), label)
     if not sysutils.run(cmd):
         return False
     # Check label consistency
     if not self.getLabel(partition) == label:
         return False
     return label
Пример #18
0
 def setLabel(self, partition, label):
     label = self.availableLabel(label)
     cmd_path = requires("e2label")
     cmd = "%s %s %s" % (cmd_path, partition.getPath(), label)
     if not sysutils.run(cmd):
         return False
     # Check label consistency
     if not self.getLabel(partition) == label:
         return False
     return label
Пример #19
0
    def execute(self):
        ctx.mainScreen.disableNext()

        ctx.debugger.log("Show reboot dialog.")
        InfoDialog(_("Press <b>Reboot</b> button to restart your system."), _("Reboot"))

        ctx.yali.info.updateAndShow(_('<b>Rebooting system. Please wait!</b>'))

        # remove cd...
        if not ctx.yali.install_type == YALI_FIRSTBOOT:
            ctx.debugger.log("Trying to eject the CD.")
            sysutils.ejectCdrom()

        ctx.debugger.log("Yali, reboot calling..")

        ctx.mainScreen.processEvents()
        sysutils.run("sync")
        time.sleep(4)
        sysutils.reboot()
Пример #20
0
    def setLabel(self, partition, label):
        label = self.availableLabel(label)
        cmd_path = requires("mkswap")
        cmd = "%s -v1 -L %s %s" % (cmd_path, label, partition.getPath())
        if not sysutils.run(cmd):
            return False

        # Swap on
        sysutils.swapOn(partition.getPath())

        return label
Пример #21
0
    def setLabel(self, partition, label):
        label = self.availableLabel(label)
        cmd_path = requires("mkswap")
        cmd = "%s -v1 -L %s %s" % (cmd_path, label, partition.getPath())
        if not sysutils.run(cmd):
            return False

        # Swap on
        sysutils.swap_on(partition.getPath())

        return label
Пример #22
0
    def execute(self):
        ctx.mainScreen.disableNext()

        ctx.debugger.log("Show reboot dialog.")
        InfoDialog(_("Press <b>Reboot</b> button to restart your system."),
                   _("Reboot"))

        ctx.yali.info.updateAndShow(_('<b>Rebooting system. Please wait!</b>'))

        # remove cd...
        if not ctx.yali.install_type == YALI_FIRSTBOOT:
            ctx.debugger.log("Trying to eject the CD.")
            sysutils.ejectCdrom()

        ctx.debugger.log("Yali, reboot calling..")

        ctx.mainScreen.processEvents()
        sysutils.run("sync")
        time.sleep(4)
        sysutils.reboot()
Пример #23
0
    def resize(self, size_mb, partition):
        """ Resize given partition as given size """
        minsize = self.minResizeMB(partition)
        if size_mb < minsize:
            size_mb = minsize
        cmd_path = requires("resize2fs")

        # Check before resize
        self.preResize(partition)

        res = sysutils.run("resize2fs",[partition.getPath(), "%sM" %(size_mb)])
        if not res:
            raise FSError, "Resize failed on %s" % (partition.getPath())
        return True
Пример #24
0
    def resize(self, size_mb, partition):
        minsize = self.minResizeMB(partition)
        if size_mb < minsize:
            size_mb = minsize

        if not self.preResize(partition):
            raise FSCheckError, _("Partition is not ready for resizing. Check it before installation.")

        cmd_path = requires("btrfsctl")
        cmd = "%s -r %dm -A %s" % (cmd_path, size_mb, partition.getPath())
        if not sysutils.run(cmd):
            raise FSError, "Resize failed on %s " % (partition.getPath())

        return True
Пример #25
0
    def resize(self, size_mb, partition):
        minsize = self.minResizeMB(partition)
        if size_mb < minsize:
            size_mb = minsize

        if not self.resizeSilent(size_mb, partition) or not self.preResize(partition):
            raise FSCheckError, _("The filesystem of '%s' partition is NTFS, and this partition \nwas not closed properly.Please restart your system and close \nthis partition properly!After this operation, start Pardus \ninstallation again!") % partition.getPath()

        cmd_path = requires("ntfsresize")
        cmd = "%s -P -ff -s %dM %s" % (cmd_path, size_mb, partition.getPath())

        if not sysutils.run(cmd):
            raise FSError, _("Resize failed on %s " % partition.getPath())

        return True
Пример #26
0
    def resize(self, size_mb, partition):
        minsize = self.minResizeMB(partition)
        if size_mb < minsize:
            size_mb = minsize

        if not self.resizeSilent(size_mb, partition) or not self.preResize(partition):
            raise FSCheckError, _("Partition is not ready for resizing. Check it before installation.")

        cmd_path = requires("ntfsresize")
        cmd = "%s -ff -s %dM %s" % (cmd_path, size_mb, partition.getPath())

        if not sysutils.run(cmd):
            raise FSError, _("Resize failed on %s " % partition.getPath())

        return True
Пример #27
0
    def resize(self, size_mb, partition):
        """ Resize given partition as given size """
        minsize = self.minResizeMB(partition)
        if size_mb < minsize:
            size_mb = minsize
        cmd_path = requires("resize2fs")

        # Check before resize
        self.preResize(partition)

        res = sysutils.run(
            "resize2fs",
            [partition.getPath(), "%sM" % (size_mb)])
        if not res:
            raise FSError, "Resize failed on %s" % (partition.getPath())
        return True
Пример #28
0
    def resize(self, size_mb, partition):
        minsize = self.minResizeMB(partition)
        if size_mb < minsize:
            size_mb = minsize

        if not self.preResize(partition):
            raise FSCheckError, _(
                "Partition is not ready for resizing. Check it before installation."
            )

        cmd_path = requires("btrfsctl")
        cmd = "%s -r %dm -A %s" % (cmd_path, size_mb, partition.getPath())
        if not sysutils.run(cmd):
            raise FSError, "Resize failed on %s " % (partition.getPath())

        return True
Пример #29
0
    def resize(self, size_mb, partition):
        minsize = self.minResizeMB(partition)
        if size_mb < minsize:
            size_mb = minsize

        if not self.resizeSilent(size_mb,
                                 partition) or not self.preResize(partition):
            raise FSCheckError, _(
                "Partition is not ready for resizing. Check it before installation."
            )

        cmd_path = requires("ntfsresize")
        cmd = "%s -P -ff -s %dM %s" % (cmd_path, size_mb, partition.getPath())

        if not sysutils.run(cmd):
            raise FSError, _("Resize failed on %s " % partition.getPath())

        return True
Пример #30
0
    def resize(self, size_mb, partition):
        minsize = self.minResizeMB(partition)
        if size_mb < minsize:
            size_mb = minsize

        if not self.resizeSilent(size_mb,
                                 partition) or not self.preResize(partition):
            raise FSCheckError, _("The filesystem of '%s' partition is NTFS, and this partition \n " \
                                  "was not closed properly. Please restart your system and close \n " \
                                  "this partition properly! After this operation, start Pardus \n " \
                                  "installation again!" % partition.getPath())

        cmd_path = requires("ntfsresize")
        cmd = "%s -P -f -s %dM %s" % (cmd_path, size_mb, partition.getPath())

        if not sysutils.run(cmd):
            raise FSError, _("Resize failed on %s " % partition.getPath())

        return True
Пример #31
0
    def format(self, partition):
        """ Format the given partition """
        self.preFormat(partition)

        cmd_path = requires("mkfs.%s" % self.name())

        # bug 5616: ~100MB reserved-blocks-percentage
        reserved_percentage = int(math.ceil(100.0 * 100.0 / partition.getMB()))

        # Use hashed b-trees to speed up lookups in large directories
        cmd = "%s -O dir_index -q -j -m %d %s" % (cmd_path,
                                                  reserved_percentage,
                                                  partition.getPath())

        res = sysutils.run(cmd)
        if not res:
            raise YaliException, "%s format failed: %s" % (self.name(), partition.getPath())

        # for Disabling Lengthy Boot-Time Checks
        self.tune2fs(partition)
Пример #32
0
    def format(self, partition):
        """ Format the given partition """
        self.preFormat(partition)

        cmd_path = requires("mkfs.%s" % self.name())

        # bug 5616: ~100MB reserved-blocks-percentage
        reserved_percentage = int(math.ceil(100.0 * 100.0 / partition.getMB()))

        # Use hashed b-trees to speed up lookups in large directories
        cmd = "%s -O dir_index -q -j -m %d %s" % (
            cmd_path, reserved_percentage, partition.getPath())

        res = sysutils.run(cmd)
        if not res:
            raise YaliException, "%s format failed: %s" % (self.name(),
                                                           partition.getPath())

        # for Disabling Lengthy Boot-Time Checks
        self.tune2fs(partition)
Пример #33
0
def setOrderedDiskList():
    devices = detectAll()
    devices.sort()

    import yali4.gui.context as ctx

    # Check EDD Module
    if not os.path.exists("/sys/firmware/edd"):
        cmd_path = sysutils.find_executable("modprobe")
        cmd = "%s %s" % (cmd_path, "edd")
        res = sysutils.run(cmd)
        if not res:
            ctx.installData.orderedDiskList = devices
            ctx.debugger.log("ERROR : Inserting EDD Module failed !")
            return

    edd = EDD()
    sortedList = []
    edd_list = edd.list_edd_signatures()
    mbr_list = edd.list_mbr_signatures()
    edd_keys = edd_list.keys()
    edd_keys.sort()
    for bios_num in edd_keys:
        edd_sig = edd_list[bios_num]
        if mbr_list.has_key(edd_sig):
            sortedList.append(mbr_list[edd_sig])

    if len(devices) > 1:
        a = ctx.installData.orderedDiskList = sortedList
        b = devices
        # check consistency of diskList
        if not len(filter(None, map(lambda x: x in a, b))) == len(b):
            ctx.installData.orderedDiskList = devices
            ctx.isEddFailed = True
    else:
        ctx.installData.orderedDiskList = devices
Пример #34
0
def setOrderedDiskList():
    devices = detectAll()
    devices.sort()

    import yali4.gui.context as ctx

    # Check EDD Module
    if not os.path.exists("/sys/firmware/edd"):
        cmd_path = sysutils.find_executable("modprobe")
        cmd = "%s %s" % (cmd_path, "edd")
        res = sysutils.run(cmd)
        if not res:
            ctx.installData.orderedDiskList = devices
            ctx.debugger.log("ERROR : Inserting EDD Module failed !")
            return

    edd = EDD()
    sortedList = []
    edd_list = edd.list_edd_signatures()
    mbr_list = edd.list_mbr_signatures()
    edd_keys = edd_list.keys()
    edd_keys.sort()
    for bios_num in edd_keys:
        edd_sig = edd_list[bios_num]
        if mbr_list.has_key(edd_sig):
            sortedList.append(mbr_list[edd_sig])

    if len(devices) > 1:
        a = ctx.installData.orderedDiskList = sortedList
        b = devices
        # check consistency of diskList
        if not len(filter(None, map(lambda x: x in a,b))) == len(b):
            ctx.installData.orderedDiskList = devices
            ctx.isEddFailed = True
    else:
        ctx.installData.orderedDiskList = devices
Пример #35
0
 def resizeSilent(self, size_mb, partition):
     # don't do anything, just check
     cmd_path = requires("ntfsresize")
     cmd = "%s -P -n -ff -s %dM %s" % (cmd_path, size_mb,
                                       partition.getPath())
     return sysutils.run(cmd)
Пример #36
0
 def preResize(self, partition):
     """ Routine operations before resizing """
     cmd_path = requires("ntfsresize")
     cmd = "%s -P -c %s" % (cmd_path, partition.getPath())
     return sysutils.run(cmd)
Пример #37
0
def _lvmclear(args):
    try:
        return sysutils.run("lvm",args)
    except Exception:
        #FIXME:log.error
        raise LVMError, args[0]
Пример #38
0
def _lvmcapture(args):
    try:
        return sysutils.run("lvm", args, capture=True)
    except RuntimeError, (errno, msg):
        #FIXME:log.error
        raise LVMError, msg
Пример #39
0
 def preResize(self, partition):
     """ Routine operations before resizing """
     cmd_path = requires("ntfsresize")
     cmd = "%s -c %s" % (cmd_path, partition.getPath())
     return sysutils.run(cmd)
Пример #40
0
 def resizeSilent(self, size_mb, partition):
     # don't do anything, just check
     cmd_path = requires("ntfsresize")
     cmd = "%s -n -ff -s %dM %s" % (cmd_path, size_mb, partition.getPath())
     return sysutils.run(cmd)