def UnloadDirectoryBrowseButton_clicked(self): old_dir = self.unload_dir self.unload_dir = to_unicode(QFileDialog.getExistingDirectory(self.unload_dir, self)) if not len(self.unload_dir): return elif not utils.is_path_writable(self.unload_dir): self.form.FailureUI(self.__tr("<p><b>The unload directory path you entered is not valid.</b><p>The directory must exist and you must have write permissions.")) self.unload_dir = old_dir else: self.UnloadDirectoryEdit.setText(self.unload_dir) os.chdir(self.unload_dir) user_conf.setWorkingDirectory(self.unload_dir)
def UnloadDirectoryBrowseButton_clicked(self): old_dir = self.unload_dir self.unload_dir = to_unicode( QFileDialog.getExistingDirectory(self.unload_dir, self)) if not len(self.unload_dir): return elif not utils.is_path_writable(self.unload_dir): self.form.FailureUI( self.__tr( "<p><b>The unload directory path you entered is not valid.</b><p>The directory must exist and you must have write permissions." )) self.unload_dir = old_dir else: self.UnloadDirectoryEdit.setText(self.unload_dir) os.chdir(self.unload_dir) user_conf.setWorkingDirectory(self.unload_dir)
def unloadButton_clicked(self): was_cancelled = False self.busy = True self.unloadButton.setEnabled(False) self.unload_dir = to_unicode(self.UnloadDirectoryEdit.text()) dir_error = False try: try: os.chdir(self.unload_dir) except OSError: log.error("Directory not found: %s" % self.unload_dir) dir_error = True if dir_error or not utils.is_path_writable(self.unload_dir): self.form.FailureUI(self.__tr("<p><b>The unload directory path is not valid.</b><p>Please enter a new path and try again.")) return unload_list = [] i = self.IconView.firstItem() self.total_size = 0 while i is not None: if i.isSelected(): unload_list.append((i.path, i.size, i.mime_type, i.mime_subtype)) self.total_size += i.size i = i.nextItem() if self.total_size == 0: self.form.FailureUI(self.__tr("<p><b>No files are selected to unload.</b><p>Please select one or more files to unload and try again.")) return self.total_complete = 0 self.progress_dlg = QProgressDialog(self.__tr("Unloading card..."), \ self.__tr("Cancel"), 100, self, "progress", 1) self.progress_dlg.setCaption(self.__tr("HP Device Manager")) self.progress_dlg.setMinimumDuration(0) self.progress_dlg.setProgress(0) qApp.processEvents() if self.removal_option == 0: # Leave files total_size, total_time, was_cancelled = \ self.pc.unload(unload_list, self.updateStatusProgressBar, None, True) elif self.removal_option == 1: # remove selected total_size, total_time, was_cancelled = \ self.pc.unload(unload_list, self.updateStatusProgressBar, None, False) else: # remove all total_size, total_time, was_cancelled = \ self.pc.unload(unload_list, self.updateStatusProgressBar, None, False) # TODO: Remove remainder of files self.progress_dlg.close() self.progress_dlg = None # TODO: #self.pc.device.sendEvent(EVENT_PCARD_FILES_TRANSFERED) if self.removal_option != 0: # remove selected or remove all self.unload_list = self.pc.get_unload_list() self.total_number = 0 self.total_size = 0 self.item_map = {} self.total_complete = 0 self.updateIconView() if was_cancelled: self.form.FailureUI(self.__tr("<b>Unload cancelled at user request.</b>")) else: pass finally: self.busy = False
def unloadButton_clicked(self): was_cancelled = False self.busy = True self.unloadButton.setEnabled(False) self.unload_dir = to_unicode(self.UnloadDirectoryEdit.text()) dir_error = False try: try: os.chdir(self.unload_dir) except OSError: log.error("Directory not found: %s" % self.unload_dir) dir_error = True if dir_error or not utils.is_path_writable(self.unload_dir): self.form.FailureUI( self.__tr( "<p><b>The unload directory path is not valid.</b><p>Please enter a new path and try again." )) return unload_list = [] i = self.IconView.firstItem() self.total_size = 0 while i is not None: if i.isSelected(): unload_list.append( (i.path, i.size, i.mime_type, i.mime_subtype)) self.total_size += i.size i = i.nextItem() if self.total_size == 0: self.form.FailureUI( self.__tr( "<p><b>No files are selected to unload.</b><p>Please select one or more files to unload and try again." )) return self.total_complete = 0 self.progress_dlg = QProgressDialog(self.__tr("Unloading card..."), \ self.__tr("Cancel"), 100, self, "progress", 1) self.progress_dlg.setCaption(self.__tr("HP Device Manager")) self.progress_dlg.setMinimumDuration(0) self.progress_dlg.setProgress(0) qApp.processEvents() if self.removal_option == 0: # Leave files total_size, total_time, was_cancelled = \ self.pc.unload(unload_list, self.updateStatusProgressBar, None, True) elif self.removal_option == 1: # remove selected total_size, total_time, was_cancelled = \ self.pc.unload(unload_list, self.updateStatusProgressBar, None, False) else: # remove all total_size, total_time, was_cancelled = \ self.pc.unload(unload_list, self.updateStatusProgressBar, None, False) # TODO: Remove remainder of files self.progress_dlg.close() self.progress_dlg = None # TODO: #self.pc.device.sendEvent(EVENT_PCARD_FILES_TRANSFERED) if self.removal_option != 0: # remove selected or remove all self.unload_list = self.pc.get_unload_list() self.total_number = 0 self.total_size = 0 self.item_map = {} self.total_complete = 0 self.updateIconView() if was_cancelled: self.form.FailureUI( self.__tr("<b>Unload cancelled at user request.</b>")) else: pass finally: self.busy = False