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 directories..."), "red") unmountDirs() 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") unmountDirs() return False
def __createImage(self, src, dst): createUSBDirs(dst) self.utils.cprint(_("Creating boot manager..."), "yellow") if createSyslinux(dst): self.utils.cprint(_("Could not create boot manager."), "red") return False self.__copyImage(self.iso_dir, dst) self.utils.cprint(_("Unmounting image and USB disk..."), "green") unmountDirs() 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.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: dst = tempfile.mkdtemp(suffix="_usbPuding") cmd = "mount -t vfat %s %s" % (device, dst) self.utils.cprint(_("Mounting USB device..."), "green") runCommand(cmd) self.utils.cprint(_("Mounting image..."), "green") cmd = "fuseiso %s %s" % (src, self.iso_dir) 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(self.iso_dir, dst) if self.__checkDiskInfo(dst, tools.getTotalSize()): self.__createImage(src, dst) else: self.utils.cprint(_("The path you have typed as second argument is invalid. Please check the USB directory."), "red") unmountDirs() sys.exit(1)