Esempio n. 1
0
    def parse_args(self, parser):
        parser.add_option("-l",
                          "--license",
                          dest="license",
                          action="store_true",
                          help=_("show program's license info and exit"))
        parser.add_option("-c",
                          "--create",
                          dest="create",
                          action="store_true",
                          help=_("create Pardus USB image from console"))

        return parser.parse_args()
Esempio n. 2
0
    def verify_iso_checksum(self, src):
        import hashlib

        checksum = hashlib.md5()
        isofile = file(src, "rb")
        size = self.bytes
        total = 0

        while size:
            data = isofile.read(size)
            checksum.update(data)
            size = len(data)
            total += size
            digit  = total / self.bytes
            self.fProgressbar(self.wheel, self.tour, digit)

        print("\b\b%s." % _("Finished"))

        src_md5 = checksum.hexdigest()

        for release in releases:
            if src_md5 in release['md5']:
                return release['name'], release['md5'], release['url']

        return False
Esempio n. 3
0
    def verify_iso_checksum(self, src):
        import hashlib

        checksum = hashlib.md5()
        isofile = file(src, "rb")
        size = self.bytes
        total = 0

        while size:
            data = isofile.read(size)
            checksum.update(data)
            size = len(data)
            total += size
            digit = total / self.bytes
            self.fProgressbar(self.wheel, self.tour, digit)

        print("\b\b%s." % _("Finished"))

        src_md5 = checksum.hexdigest()

        for release in releases:
            if src_md5 in release['md5']:
                return release['name'], release['md5'], release['url']

        return False
Esempio n. 4
0
    def __create_image(self, src, dst):
        create_USB_dirs(dst)

        self.utils.cprint(_("Creating boot manager..."), "yellow")
        if create_syslinux(self.iso_dir, dst):
            self.utils.cprint(_("Could not create boot manager."), "red")

            return False

        self.__copy_image(self.iso_dir, dst)

        self.utils.cprint(_("Unmounting image and USB disk..."), "green")
        unmount_dirs()

        self.utils.cprint(_("USB disk is ready. Now you can install or run Pardus from your USB disk."), "brightgreen")

        return True
Esempio n. 5
0
    def __check_source(self, src):
        if not os.path.isfile(src):
            self.utils.cprint(_("The path is invalid, please specify an image path."), "red")

            return False

        self.utils.cprint(_("Calculating checksum..."), "green")

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

            self.utils.cprint(_("Source Informations:"), "brightgreen")
            self.utils.cprint("    %s:" % _("Image Path"), "green", True)
            print(src)
            self.utils.cprint("    %s:" % _("Name"), "green", True)
            print(name)
            self.utils.cprint("    Md5sum:", "green", True)
            print(md5)
            self.utils.cprint("    %s:" % _("Download URL"), "green", True)
            print(url)

            return True

        # FIX ME: Bad Code..
        except TypeError:
            self.utils.cprint(_("The checksum of the source cannot be validated. Please specify a correct source or be sure that you have downloaded the source correctly."), "red")

            return False
Esempio n. 6
0
    def __check_source(self, src):
        if not os.path.isfile(src):
            self.utils.cprint(
                _("The path is invalid, please specify an image path."), "red")

            return False

        self.utils.cprint(_("Calculating checksum..."), "green")

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

            self.utils.cprint(_("Source Informations:"), "brightgreen")
            self.utils.cprint("    %s:" % _("Image Path"), "green", True)
            print(src)
            self.utils.cprint("    %s:" % _("Name"), "green", True)
            print(name)
            self.utils.cprint("    Md5sum:", "green", True)
            print(md5)
            self.utils.cprint("    %s:" % _("Download URL"), "green", True)
            print(url)

            return True

        # FIX ME: Bad Code..
        except TypeError:
            self.utils.cprint(
                _("The checksum of the source cannot be validated. Please specify a correct source or be sure that you have downloaded the source correctly."
                  ), "red")

            return False
Esempio n. 7
0
    def __create_image(self, src, dst):
        create_USB_dirs(dst)

        self.utils.cprint(_("Creating boot manager..."), "yellow")
        if create_syslinux(self.iso_dir, dst):
            self.utils.cprint(_("Could not create boot manager."), "red")

            return False

        self.__copy_image(self.iso_dir, dst)

        self.utils.cprint(_("Unmounting image and USB disk..."), "green")
        unmount_dirs()

        self.utils.cprint(
            _("USB disk is ready. Now you can install or run Pardus from your USB disk."
              ), "brightgreen")

        return True
Esempio n. 8
0
    def main(self):
        description = _("Puding is an USB image creator for Pardus Linux.")
        parser = OptionParser(description=description, version=VERSION)
        (opts, args) = self.parse_args(parser)

        if opts.create:
            if not os.getuid() == 0:
                print(
                    _("You need superuser permissions to run this application."
                      ))

                sys.exit(0)

            try:
                from puding.ui.cmd import puding_cmd

                source = os.path.realpath(args[0])

                try:
                    destination = os.path.realpath(args[1])

                except:
                    destination = None

                puding_cmd.Create(source, destination)

            except IndexError:
                print(_("Invalid usage. Example:"))
                print("\tpuding --create /mnt/archive/Pardus-2009.iso\n")
                print(
                    _("(If you know directory path that is your USB device mount point)"
                      ))
                print(
                    "\tpuding --create /mnt/archive/Pardus-2009.iso /media/disk"
                )

        elif opts.license:
            print(LICENSE)

        else:
            from puding.ui.qt.puding_qt import RunApplicationInterface

            RunApplicationInterface()
Esempio n. 9
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)
Esempio n. 10
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)
Esempio n. 11
0
    def __copy_image(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.copy_file(path)
Esempio n. 12
0
    def __copy_image(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.copy_file(path)
Esempio n. 13
0
    def main(self):
        description = _("Puding is an USB image creator for Pardus Linux.")
        parser = OptionParser(description = description, version = VERSION)
        (opts, args) = self.parse_args(parser)

        if opts.create:
            if not os.getuid() == 0:
                print(_("You need superuser permissions to run this application."))

                sys.exit(0)

            try:
                from puding.ui.cmd import puding_cmd

                source = os.path.realpath(args[0])

                try:
                    destination = os.path.realpath(args[1])

                except:
                    destination = None

                puding_cmd.Create(source, destination)

            except IndexError:
                print(_("Invalid usage. Example:"))
                print("\tpuding --create /mnt/archive/Pardus-2009.iso\n")
                print(_("(If you know directory path that is your USB device mount point)"))
                print("\tpuding --create /mnt/archive/Pardus-2009.iso /media/disk")

        elif opts.license:
            print(LICENSE)

        else:
            from puding.ui.qt.puding_qt import RunApplicationInterface

            RunApplicationInterface()
Esempio n. 14
0
    def parse_args(self, parser):
        parser.add_option("-l", "--license", dest = "license", action = "store_true", help = _("show program's license info and exit"))
        parser.add_option("-c", "--create", dest = "create", action = "store_true", help = _("create Pardus USB image from console"))

        return parser.parse_args()
Esempio n. 15
0
                try:
                    destination = os.path.realpath(args[1])

                except:
                    destination = None

                puding_cmd.Create(source, destination)

            except IndexError:
                print(_("Invalid usage. Example:"))
                print("\tpuding --create /mnt/archive/Pardus-2009.iso\n")
                print(_("(If you know directory path that is your USB device mount point)"))
                print("\tpuding --create /mnt/archive/Pardus-2009.iso /media/disk")

        elif opts.license:
            print(LICENSE)

        else:
            from puding.ui.qt.puding_qt import RunApplicationInterface

            RunApplicationInterface()


if __name__ == "__main__":
    try:
        Options().main()

    except KeyboardInterrupt:
        print(_("\nQuitting, please wait."))
        unmount_dirs()
Esempio n. 16
0
    def __check_disk_info(self, dst, total_size):
        (capacity, available, used) = get_disk_info(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 directories..."), "red")
            unmount_dirs()

            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")
        unmount_dirs()

        return False
Esempio n. 17
0
                    destination = None

                puding_cmd.Create(source, destination)

            except IndexError:
                print(_("Invalid usage. Example:"))
                print("\tpuding --create /mnt/archive/Pardus-2009.iso\n")
                print(
                    _("(If you know directory path that is your USB device mount point)"
                      ))
                print(
                    "\tpuding --create /mnt/archive/Pardus-2009.iso /media/disk"
                )

        elif opts.license:
            print(LICENSE)

        else:
            from puding.ui.qt.puding_qt import RunApplicationInterface

            RunApplicationInterface()


if __name__ == "__main__":
    try:
        Options().main()

    except KeyboardInterrupt:
        print(_("\nQuitting, please wait."))
        unmount_dirs()
Esempio n. 18
0
    def __check_disk_info(self, dst, total_size):
        (capacity, available, used) = get_disk_info(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 directories..."), "red")
            unmount_dirs()

            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")
        unmount_dirs()

        return False
Esempio n. 19
0
    def __ask_destination(self):
        self.drives = self.partutils.return_drives()
        if len(self.drives) == 1:
            # FIX ME: If disk is unmounted, you should mount it before return process!
            # It returns mount point directory.
            device = self.drives.keys()[0]

        else:
            drive_no = 0

            self.utils.cprint(_("Devices:"), "brightwhite")

            for drive in self.drives:
                drive_no += 1

                # FIX ME: Bad coding..
                self.utils.cprint("%d) %s:" % (drive_no, drive), "brightgreen")
                self.utils.cprint("    %s:" % _("Label"), "green", True)
                print(self.drives[drive]["label"])

                self.utils.cprint("    %s:" % _("Parent"), "green", True)
                print(str(self.drives[drive]["parent"]))

                self.utils.cprint("    %s:" % _("Mount Point"), "green", True)
                mount_dir = self.drives[drive]["mount"]
                if not mount_dir:
                    print("%s (%s)" % (self.iso_dir,  _("not mounted")))
                else:
                    print(mount_dir)

                self.utils.cprint("    %s:" % _("Unmount"), "green", True)
                print(str(self.drives[drive]["unmount"]))

                self.utils.cprint("    UUID:", "green", True)
                print(self.drives[drive]["uuid"])

                self.utils.cprint("    %s:" % _("File System Version"), "green", True)
                print(self.drives[drive]["fsversion"])

                self.utils.cprint("    %s:" % _("File System Type"), "green", True)
                print("%s\n" % self.drives[drive]["fstype"])

            try:
                part_number = int(raw_input(_("USB devices or partitions have found more than one. Please choose one:") + " "))

            except ValueError:
                self.utils.cprint(_("Please enter a number between 0 - %d." % (drive_no + 1)), "red")

                sys.exit(1)

            try:
                device = self.drives.keys()[part_number - 1]

            except IndexError:
                self.utils.cprint(_("You must enter a number between 0 - %d." % (drive_no + 1)), "red")

                sys.exit(1)

        destination = self.drives[device]["mount"]

        return device, destination
Esempio n. 20
0
    def __ask_destination(self):
        self.drives = self.partutils.return_drives()
        if len(self.drives) == 1:
            # FIX ME: If disk is unmounted, you should mount it before return process!
            # It returns mount point directory.
            device = self.drives.keys()[0]

        else:
            drive_no = 0

            self.utils.cprint(_("Devices:"), "brightwhite")

            for drive in self.drives:
                drive_no += 1

                # FIX ME: Bad coding..
                self.utils.cprint("%d) %s:" % (drive_no, drive), "brightgreen")
                self.utils.cprint("    %s:" % _("Label"), "green", True)
                print(self.drives[drive]["label"])

                self.utils.cprint("    %s:" % _("Parent"), "green", True)
                print(str(self.drives[drive]["parent"]))

                self.utils.cprint("    %s:" % _("Mount Point"), "green", True)
                mount_dir = self.drives[drive]["mount"]
                if not mount_dir:
                    print("%s (%s)" % (self.iso_dir, _("not mounted")))
                else:
                    print(mount_dir)

                self.utils.cprint("    %s:" % _("Unmount"), "green", True)
                print(str(self.drives[drive]["unmount"]))

                self.utils.cprint("    UUID:", "green", True)
                print(self.drives[drive]["uuid"])

                self.utils.cprint("    %s:" % _("File System Version"),
                                  "green", True)
                print(self.drives[drive]["fsversion"])

                self.utils.cprint("    %s:" % _("File System Type"), "green",
                                  True)
                print("%s\n" % self.drives[drive]["fstype"])

            try:
                part_number = int(
                    raw_input(
                        _("USB devices or partitions have found more than one. Please choose one:"
                          ) + " "))

            except ValueError:
                self.utils.cprint(
                    _("Please enter a number between 0 - %d." %
                      (drive_no + 1)), "red")

                sys.exit(1)

            try:
                device = self.drives.keys()[part_number - 1]

            except IndexError:
                self.utils.cprint(
                    _("You must enter a number between 0 - %d." %
                      (drive_no + 1)), "red")

                sys.exit(1)

        destination = self.drives[device]["mount"]

        return device, destination