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