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)
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)
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
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 __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)
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)
class Create(QtGui.QMainWindow, qtMain.Ui_MainWindow): def __init__(self, parent = None): self.iso_dir = tempfile.mkdtemp(suffix="_isoPuding") super(Create, self).__init__(parent) self.setupUi(self) self.connect(self.button_quit, QtCore.SIGNAL("clicked()"), QtCore.SLOT("close()")) self.connect(self.actionQuit, QtCore.SIGNAL("triggered()"), QtCore.SLOT("close()")) @QtCore.pyqtSignature("bool") def on_button_browse_image_clicked(self): filename = QtGui.QFileDialog.getOpenFileName(self, self.tr("Select CD Image"), os.environ["HOME"], "%s (*.iso *.img)" % self.tr("Images")) self.line_image.setText(filename) @QtCore.pyqtSignature("bool") def on_button_browse_disk_clicked(self): self.browse_disk = SelectDisk() if self.browse_disk.exec_() == QtGui.QDialog.Accepted: dirname = self.browse_disk.getSelectedDirectory() if not dirname: self.warningDialog(self.tr("Warning"), self.tr("You should select a valid directory.")) else: self.line_disk.setText(QtCore.QString(dirname)) @QtCore.pyqtSignature("bool") def on_actionAbout_triggered(self): about_puding = About() about_puding.exec_() @QtCore.pyqtSignature("bool") 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) def warningDialog(self, title, message,): QtGui.QMessageBox.warning(self, title, message, QtGui.QMessageBox.Ok) def questionDialog(self, title, message): return QtGui.QMessageBox.question(self, title, message, QtGui.QMessageBox.Cancel | QtGui.QMessageBox.Ok) def __getSourceInfo(self, src): if QtCore.QString(src).isEmpty(): self.warningDialog(self.tr("CD Image is Invalid"), self.tr("Please set an CD image path.")) return False if not os.path.isfile(src): self.warningDialog(self.tr("CD Image is Invalid"), self.tr("Please check the CD image path.")) return False iso_size = getIsoSize(src) iso_size_progress = iso_size / increment_value check_iso = ProgressBar(title = self.tr("Verify Checksum"), message = self.tr("The checksum of the source is checking now..."), max_value = iso_size_progress) pi = ProgressIncrementChecksum(check_iso, src) # FIX ME: Why is it in here? def closeDialog(): pi.quit() check_iso.close() QtCore.QObject.connect(pi, QtCore.SIGNAL("incrementProgress()"), check_iso.incrementProgress) QtCore.QObject.connect(pi, QtCore.SIGNAL("closeProgressDialog()"), closeDialog) pi.start() check_iso.exec_() if not pi.checksum(): message = """The checksum of the source cannot be validated. Please specify a correct source or be sure that you have downloaded the source correctly.""" self.warningDialog(self.tr("Checksum invalid"), self.tr(message)) return False return pi.checksum() def __checkDestination(self, dst): if QtCore.QString(dst).isEmpty(): return False return os.path.ismount(str(dst)) def __createImage(self, src, dst): file_list = self.tools.file_list max_value = self.tools.getNumberOfFiles() create_image = ProgressBar(title = self.tr("Creating Image"), message = self.tr("Creating image..."), max_value = max_value) pi = ProgressIncrementCopy(create_image, self.iso_dir, dst) def closeDialog(): pi.quit() create_image.close() QtCore.QObject.connect(pi, QtCore.SIGNAL("incrementProgress()"), create_image.incrementProgress) QtCore.QObject.connect(pi, QtCore.SIGNAL("updateLabel"), pi.updateLabel) QtCore.QObject.connect(pi, QtCore.SIGNAL("closeProgressDialog()"), closeDialog) pi.start() create_image.exec_() self.warningDialog(self.tr("USB Image is Ready"), self.tr("Your USB image is ready. Now you can install or run Pardus from USB storage.")) return True
class Create(QtGui.QMainWindow, qtMain.Ui_MainWindow): def __init__(self, parent=None): self.iso_dir = tempfile.mkdtemp(suffix="_isoPuding") super(Create, self).__init__(parent) self.setupUi(self) self.connect(self.button_quit, QtCore.SIGNAL("clicked()"), QtCore.SLOT("close()")) self.connect(self.actionQuit, QtCore.SIGNAL("triggered()"), QtCore.SLOT("close()")) @QtCore.pyqtSignature("bool") def on_button_browse_image_clicked(self): filename = QtGui.QFileDialog.getOpenFileName( self, self.tr("Select CD Image"), os.environ["HOME"], "%s (*.iso *.img)" % self.tr("Images")) self.line_image.setText(filename) @QtCore.pyqtSignature("bool") def on_button_browse_disk_clicked(self): self.browse_disk = SelectDisk() if self.browse_disk.exec_() == QtGui.QDialog.Accepted: dirname = self.browse_disk.getSelectedDirectory() if not dirname: self.warningDialog( self.tr("Warning"), self.tr("You should select a valid directory.")) else: self.line_disk.setText(QtCore.QString(dirname)) @QtCore.pyqtSignature("bool") def on_actionAbout_triggered(self): about_puding = About() about_puding.exec_() @QtCore.pyqtSignature("bool") 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) def warningDialog( self, title, message, ): QtGui.QMessageBox.warning(self, title, message, QtGui.QMessageBox.Ok) def questionDialog(self, title, message): return QtGui.QMessageBox.question( self, title, message, QtGui.QMessageBox.Cancel | QtGui.QMessageBox.Ok) def __getSourceInfo(self, src): if QtCore.QString(src).isEmpty(): self.warningDialog(self.tr("CD Image is Invalid"), self.tr("Please set an CD image path.")) return False if not os.path.isfile(src): self.warningDialog(self.tr("CD Image is Invalid"), self.tr("Please check the CD image path.")) return False iso_size = getIsoSize(src) iso_size_progress = iso_size / increment_value check_iso = ProgressBar( title=self.tr("Verify Checksum"), message=self.tr("The checksum of the source is checking now..."), max_value=iso_size_progress) pi = ProgressIncrementChecksum(check_iso, src) # FIX ME: Why is it in here? def closeDialog(): pi.quit() check_iso.close() QtCore.QObject.connect(pi, QtCore.SIGNAL("incrementProgress()"), check_iso.incrementProgress) QtCore.QObject.connect(pi, QtCore.SIGNAL("closeProgressDialog()"), closeDialog) pi.start() check_iso.exec_() if not pi.checksum(): message = """The checksum of the source cannot be validated. Please specify a correct source or be sure that you have downloaded the source correctly.""" self.warningDialog(self.tr("Checksum invalid"), self.tr(message)) return False return pi.checksum() def __checkDestination(self, dst): if QtCore.QString(dst).isEmpty(): return False return os.path.ismount(str(dst)) def __createImage(self, src, dst): file_list = self.tools.file_list max_value = self.tools.getNumberOfFiles() create_image = ProgressBar(title=self.tr("Creating Image"), message=self.tr("Creating image..."), max_value=max_value) pi = ProgressIncrementCopy(create_image, self.iso_dir, dst) def closeDialog(): pi.quit() create_image.close() QtCore.QObject.connect(pi, QtCore.SIGNAL("incrementProgress()"), create_image.incrementProgress) QtCore.QObject.connect(pi, QtCore.SIGNAL("updateLabel"), pi.updateLabel) QtCore.QObject.connect(pi, QtCore.SIGNAL("closeProgressDialog()"), closeDialog) pi.start() create_image.exec_() self.warningDialog( self.tr("USB Image is Ready"), self. tr("Your USB image is ready. Now you can install or run Pardus from USB storage." )) return True