示例#1
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.__check_destination(dst):
            self.warning_dialog(self.tr("Directory is Invalid"), self.tr("Please check the USB disk path."))

            return False

        try:
            (name, md5, url) = self.__get_source_info(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 = get_mounted(dst)
        (capacity, available, used) = get_disk_info(dst)

        # Mount iso
        if not os.path.ismount(self.iso_dir):
            cmd = "fuseiso %s %s" % (src, self.iso_dir)
            if run_command(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.get_total_size()

        if available < total_size:
            self.warning_dialog("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:
                create_USB_dirs(dst)
                self.__create_image(src, dst)

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

        run_command("fusermount -u %s" % self.iso_dir)
示例#2
0
    def __copyImage(self, src, dst):
        # FIX ME: Now, Puding supports only Pardus..
        from pardusTools import Main

        tools = Main(src, dst)
        file_list = tools.file_list

        for path in file_list:
            file_name = os.path.split(path)[-1]
            self.utils.cprint("%s:" % _("Copying"), "green", True)
            self.utils.cprint(file_name, "brightyellow")
            tools.copyFile(path)
示例#3
0
    def __init__(self, src, dst):
        self.utils = Utils()
        self.progressbar = ProgressBar(src)
        self.iso_dir = tempfile.mkdtemp(suffix="_isoPuding")

        if not dst:
            self.partutils = PartitionUtils()

            if not self.partutils.detect_removable_drives():
                self.utils.cprint(_("USB device not found."), "red")
                sys.exit()

            else:
                device, dst = self.__ask_destination()

                # FIX ME: You should not use it.
                if not dst:
                    dst = tempfile.mkdtemp(suffix="_usbPuding")
                    cmd = "mount -t vfat %s %s" % (device, dst)
                    self.utils.cprint(_("Mounting USB device..."), "green")
                    run_command(cmd)

        self.utils.cprint(_("Mounting image..."), "green")
        cmd = "fuseiso %s %s" % (src, self.iso_dir)
        if run_command(cmd):
            self.utils.cprint(_("Could not mounted image."), "red")

            sys.exit(1)

        if self.__check_source(src) and self.__check_destination(dst):
            from pardusTools import Main

            tools = Main(self.iso_dir, dst)
            if self.__check_disk_info(dst, tools.get_total_size()):
                self.__create_image(src, dst)

        else:
            self.utils.cprint(
                _("The path you have typed as second argument is invalid. Please check the USB directory."
                  ), "red")
            unmount_dirs()

            sys.exit(1)
示例#4
0
    def __init__(self, src, dst):
        self.utils = Utils()
        self.progressbar = ProgressBar(src)

        if dst == None:
            self.partutils = PartitionUtils()

            if not self.partutils.detectRemovableDrives():
                self.utils.cprint(_("USB device not found."), "red")
                sys.exit()

            else:
                device, dst = self.__askDestination()

                # FIX ME: You should not use it.
                if not dst:
                    cmd = "mount -t vfat %s %s" % (device, MOUNT_USB)
                    self.utils.cprint(_("Mounting USB device..."), "green")
                    runCommand(cmd)
                    dst = MOUNT_USB

        self.utils.cprint(_("Mounting image..."), "green")
        cmd = "fuseiso %s %s" % (src, MOUNT_ISO)
        if runCommand(cmd):
            self.utils.cprint(_("Could not mounted image."), "red")

            sys.exit(1)

        if self.__checkSource(src) and self.__checkDestination(dst):
            from pardusTools import Main

            tools = Main(MOUNT_ISO, dst)
            if self.__checkDiskInfo(dst, tools.getTotalSize()):
                self.__createImage(src, dst)

        else:
            self.utils.cprint(
                _("The path you have typed is invalid. If you think the path is valid, make sure you have mounted USB stick to the path you gave. To check the path, you can use: mount | grep %s"
                  % dst), "red")

            sys.exit(1)