Example #1
0
    def __checkDiskInfo(self, dst, total_size):
        (capacity, available, used) = getDiskInfo(str(dst))
        if available < total_size:
            self.utils.cprint(_("There is not enough space left on your USB stick for the image."), "red")

            self.utils.cprint(_("Unmounting image..."), "red")
            runCommand("fusermount -u %s" % MOUNT_ISO)

            return False

        self.utils.cprint(_("USB disk informations:"), "brightgreen")
        self.utils.cprint("    %s:" % _("Capacity"), "green", True)
        print("%dMB" % capacity)

        self.utils.cprint("    %s:" % _("Available"), "green", True)
        print("%dMB" % available)

        self.utils.cprint("    %s:" % _("Used"), "green", True)
        print("%dMB" % used)

        print(_("\nPlease double check your path information. If you don't type the path to the USB stick correctly, you may damage your computer. Would you like to continue?"))

        answer = raw_input("%s " % _("Please type CONFIRM to continue:"))
        if answer in (_('CONFIRM'), _('confirm')):
            self.utils.cprint(_("Writing image data to USB stick!"), "green")

            return True

        self.utils.cprint(_("You did not type CONFIRM. Exiting.."), "red")

        return False
Example #2
0
    def __checkDiskInfo(self, dst, total_size):
        (capacity, available, used) = getDiskInfo(str(dst))
        if available < total_size:
            self.utils.cprint(
                _("There is not enough space left on your USB stick for the image."
                  ), "red")

            self.utils.cprint(_("Unmounting image..."), "red")
            runCommand("fusermount -u %s" % MOUNT_ISO)

            return False

        self.utils.cprint(_("USB disk informations:"), "brightgreen")
        self.utils.cprint("    %s:" % _("Capacity"), "green", True)
        print("%dMB" % capacity)

        self.utils.cprint("    %s:" % _("Available"), "green", True)
        print("%dMB" % available)

        self.utils.cprint("    %s:" % _("Used"), "green", True)
        print("%dMB" % used)

        print(
            _("\nPlease double check your path information. If you don't type the path to the USB stick correctly, you may damage your computer. Would you like to continue?"
              ))

        answer = raw_input("%s " % _("Please type CONFIRM to continue:"))
        if answer in (_('CONFIRM'), _('confirm')):
            self.utils.cprint(_("Writing image data to USB stick!"), "green")

            return True

        self.utils.cprint(_("You did not type CONFIRM. Exiting.."), "red")

        return False
Example #3
0
    def on_button_create_clicked(self):
        # FIXED issue: #1
        src = unicode(str(self.line_image.displayText()))
        dst = str(self.line_disk.displayText())

        if dst.startswith("/dev/"):
            from puding.pardusTools import Authorization

            auth = Authorization()
            auth.mount(dst, MOUNT_USB)
            dst = MOUNT_USB

        if not self.__checkDestination(dst):
            self.warningDialog(self.tr("Directory is Invalid"), self.tr("Please check the USB disk path."))

            return False

        try:
            (name, md5, url) = self.__getSourceInfo(src)

        except TypeError: # 'bool' object is not iterable
            # It's not true way, you should warn to the users with WarningDialog.
            return False

        mount_point = getMounted(dst)
        (capacity, available, used) = getDiskInfo(dst)

        # Mount iso
        if not os.path.ismount(MOUNT_ISO):
            cmd = "fuseiso %s %s" % (src, MOUNT_ISO)
            if runCommand(cmd):
                # FIX ME: Should use warning dialog.
                return False

        # FIX ME: Now Puding supports only Pardus.
        from pardusTools import Main

        self.tools = Main(MOUNT_ISO, dst)
        total_size = self.tools.getTotalSize()

        if available < total_size:
            self.warningDialog("Warning", "There is not enough space left on your USB stick for the image.")

        else:
            self.confirm_infos = ConfirmDialog(src, dst, mount_point, name, total_size, capacity, available, used)

            if self.confirm_infos.exec_() == QtGui.QDialog.Accepted:
                createUSBDirs(dst)
                self.__createImage(src, dst)

                if dst == MOUNT_USB:
                    auth.umount(dst)

        # Unmount iso
        cmd = "fusermount -u %s" % MOUNT_ISO
        if runCommand(cmd):
            # FIX ME: Should use warning dialog.
            return False
Example #4
0
    def on_button_create_clicked(self):
        # FIXED issue: #1
        src = unicode(str(self.line_image.displayText()))
        dst = str(self.line_disk.displayText())

        if dst.startswith("/dev/"):
            device = dst
            dst = tempfile.mkdtemp(suffix="_usbPuding")

            from puding.pardusTools import Authorization

            auth = Authorization()
            auth.mount(device, dst)

        if not self.__checkDestination(dst):
            self.warningDialog(self.tr("Directory is Invalid"),
                               self.tr("Please check the USB disk path."))

            return False

        try:
            (name, md5, url) = self.__getSourceInfo(src)

        except TypeError:  # 'bool' object is not iterable
            # It's not true way, you should warn to the users with WarningDialog.
            return False

        mount_point = getMounted(dst)
        (capacity, available, used) = getDiskInfo(dst)

        # Mount iso
        if not os.path.ismount(self.iso_dir):
            cmd = "fuseiso %s %s" % (src, self.iso_dir)
            if runCommand(cmd):
                # FIX ME: Should use warning dialog.
                return False

        # FIX ME: Now Puding supports only Pardus.
        from pardusTools import Main

        self.tools = Main(self.iso_dir, dst)
        total_size = self.tools.getTotalSize()

        if available < total_size:
            self.warningDialog(
                "Warning",
                "There is not enough space left on your USB stick for the image."
            )

        else:
            self.confirm_infos = ConfirmDialog(src, dst, mount_point, name,
                                               total_size, capacity, available,
                                               used)

            if self.confirm_infos.exec_() == QtGui.QDialog.Accepted:
                createUSBDirs(dst)
                self.__createImage(src, dst)

                if dst.endswith("Puding"):
                    auth.umount(dst)

        runCommand("fusermount -u %s" % self.iso_dir)