Пример #1
0
    def handle(self):
        def refresh(percent, topRow, bottomRow):
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                self.tr("Integrity check {0}%").format(percent))
            self._emitHandlerSignal(HandlerSignals.RESET_ROW_RANGE, topRow, bottomRow)
            QtCore.QCoreApplication.processEvents()

        try:
            self._tool.checkActiveRepoIsNotNone()
            self._tool.checkActiveUserIsNotNone()

            rows = self._tool.gui.selectedRows()
            if len(rows) == 0:
                raise errors.MsgException(self.tr("There are no selected items."))

            items = []
            for row in rows:
                item = self._tool.gui.itemAtRow(row)
                item.table_row = row
                items.append(item)

            thread = threads.ItemIntegrityCheckerThread(
                self._tool.gui, self._tool.repo, items, self._tool.itemsLock)

            self.connect(thread, QtCore.SIGNAL("progress"),
                         lambda percents, topRow, bottomRow: refresh(percents, topRow, bottomRow))
            self.connect(thread, QtCore.SIGNAL("finished_with_1_arg"),
                         lambda errorCount: self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                                self.tr("Integrity check is done. {} Items with errors.".format(errorCount))))
            thread.start()

            stats.sendEvent("items_table.check_item_integrity_error")

        except Exception as ex:
            show_exc_info(self._tool.gui, ex)
    def handle(self):
        logger.info("OpenFileActionHandler.handle invoked")
        try:
            selFiles = self._tool.gui.selectedFiles()
            if len(selFiles) != 1:
                raise err.MsgException(self.tr("Select one file, please."))

            selFile = selFiles[0]
            assert os.path.isabs(
                selFiles[0]), "Path '{}' should be absolute".format(selFile)

            if os.path.isdir(selFile):
                self._extAppMgr.openContainingDirWithExtAppManager(selFile)
            elif os.path.isfile(selFile):
                self._extAppMgr.openFileWithExtApp(selFile)
            else:
                raise err.MsgException(
                    self.
                    tr("This is not a file and not a directory, cannot open it."
                       ))

            stats.sendEvent("file_browser.open_file")

        except Exception as ex:
            show_exc_info(self._tool.gui, ex)

        else:
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                                    self.tr("Done."), consts.STATUSBAR_TIMEOUT)
    def handle(self):
        try:
            self._tool.checkActiveRepoIsNotNone()
            self._tool.checkActiveUserIsNotNone()

            rows = self._tool.gui.selectedRows()
            if len(rows) == 0:
                raise errors.MsgException(
                    self.tr("There are no selected items."))

            startIndex = 0  #This is the index of the first image to show
            items = []
            if len(rows) == 1:
                #If there is only one selected item, pass to viewer all items in this table model
                for row in range(self._tool.gui.rowCount()):
                    items.append(self._tool.gui.itemAtRow(row))
                startIndex = rows.pop()

            else:
                for row in rows:
                    items.append(self._tool.gui.itemAtRow(row))

            iv = ImageViewer(self._tool.gui, self._tool.widgetsUpdateManager,
                             self._tool.repo, self._tool.user.login, items,
                             startIndex)
            iv.show()
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                                    self.tr("Done."), consts.STATUSBAR_TIMEOUT)

            stats.sendEvent("items_table.open_item_with_internal_image_viewer")

        except Exception as ex:
            show_exc_info(self._tool.gui, ex)
Пример #4
0
    def __buttonOkClicked(self):
        try:
            self.__checkCategoriesValid()
            return self.accept()

        except Exception as ex:
            helpers.show_exc_info(self, ex)
Пример #5
0
    def __onButtonNewCategoryClicked(self):
        try:
            categoriesCountBefore = self.ui.comboBoxCategory.count()

            text, isOk = self.__dialogs.execGetTextDialog(self,
                self.tr("Input Dialog"), self.tr("Enter the name for new category of files."),
                defaultText="Category_{}".format(categoriesCountBefore))
            if not isOk:
                return

            if helpers.is_none_or_empty(text):
                raise MsgException(self.tr("Category name should not be empty"))

            if self.__isCategoryExists(text):
                raise MsgException(self.tr("Category with given name already exists. Choose different name."))

            appDescription = ExtAppDescription(text, "<path to executable> %f", [".mp3", ".ogg"])
            self.__extAppMgrState.appDescriptions.append(appDescription)

            self.ui.comboBoxCategory.addItem(text)
            categoriesCountAfter = self.ui.comboBoxCategory.count()
            self.ui.comboBoxCategory.setCurrentIndex(categoriesCountAfter - 1)

        except Exception as ex:
            helpers.show_exc_info(self, ex)
Пример #6
0
    def handle(self):
        try:
            self._tool.checkActiveRepoIsNotNone()
            self._tool.checkActiveUserIsNotNone()

            files = self.__dialogs.getOpenFilesAndDirs(
                self._tool.gui, self.tr("Select files you want to add to the repository"))

            # NOTE: if len(files) == 0 (user haven't selected any files) then it is supposed that
            # an Item without file should be created.

            (self._itemsCreatedCount, self._filesSkippedCount, self.lastSavedItemIds) = \
                AddItemAlgorithms.addItems(self._tool, self.__dialogs, files)

            self._emitHandlerSignal(HandlerSignals.ITEM_CREATED)

            stats.sendEvent("items_table.add_items")

        except errors.CancelOperationError:
            return
        except Exception as ex:
            show_exc_info(self._tool.gui, ex)
        finally:
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                self.tr("Operation completed. Added {}, skipped {} files.")
                    .format(self._itemsCreatedCount, self._filesSkippedCount))
Пример #7
0
    def handle(self):
        try:
            self._tool.checkActiveRepoIsNotNone()

            itemIds = self._tool.gui.selectedItemIds()
            if len(itemIds) == 0:
                raise errors.MsgException(self.tr("There are no selected items."))

            dstDirPath = self._dialogs.getExistingDirectory(
                self._tool.gui, self.tr("Choose a directory path to export files into."))

            if not dstDirPath:
                raise errors.MsgException(self.tr("You haven't chosen existent directory. Operation canceled."))

            thread = threads.ExportItemsFilesThread(self, self._tool.repo, itemIds, dstDirPath)

            self._dialogs.startThreadWithWaitDialog(thread, self._tool.gui, indeterminate=False)

            self._filesExported = thread.filesExportedCount
            self._filesSkipped = thread.filesSkippedCount

            stats.sendEvent("items_table.export_items_files")

        except Exception as ex:
            show_exc_info(self._tool.gui, ex)

        else:
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                self.tr("Operation completed. Exported {}, skipped {} files."
                        .format(self._filesExported, self._filesSkipped)))
Пример #8
0
    def handle(self):
        try:
            self._tool.checkActiveRepoIsNotNone()
            self._tool.checkActiveUserIsNotNone()

            rows = self._tool.gui.selectedRows()
            if len(rows) == 0:
                raise errors.MsgException(self.tr("There are no selected items."))

            startIndex = 0 #This is the index of the first image to show
            items = []
            if len(rows) == 1:
                #If there is only one selected item, pass to viewer all items in this table model
                for row in range(self._tool.gui.rowCount()):
                    items.append(self._tool.gui.itemAtRow(row))
                startIndex = rows.pop()

            else:
                for row in rows:
                    items.append(self._tool.gui.itemAtRow(row))

            iv = ImageViewer(self._tool.gui, self._tool.widgetsUpdateManager,
                             self._tool.repo, self._tool.user.login,
                             items, startIndex)
            iv.show()
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                self.tr("Done."), consts.STATUSBAR_TIMEOUT)

            stats.sendEvent("items_table.open_item_with_internal_image_viewer")

        except Exception as ex:
            show_exc_info(self._tool.gui, ex)
Пример #9
0
    def handle(self):
        try:
            self._model.checkActiveRepoIsNotNone()
            self._model.checkActiveUserIsNotNone()

            importFromFilename = self._dialogs.getOpenFileName(
                self._model.gui, self.tr("Open Reggata Archive File"),
                self.tr("Reggata Archive File (*.raf)"))
            if not importFromFilename:
                raise MsgException(
                    self.tr("You haven't chosen a file. Operation canceled."))

            thread = ImportItemsThread(self, self._model.repo,
                                       importFromFilename,
                                       self._model.user.login)

            self._dialogs.startThreadWithWaitDialog(thread,
                                                    self._model.gui,
                                                    indeterminate=False)

            self._emitHandlerSignal(HandlerSignals.ITEM_CREATED)

            #TODO: display information about how many items were imported
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                                    self.tr("Operation completed."),
                                    STATUSBAR_TIMEOUT)

            stats.sendEvent("main_window.import_items")

        except Exception as ex:
            show_exc_info(self._model.gui, ex)
    def handle(self):
        try:
            self._tool.checkActiveRepoIsNotNone()
            self._tool.checkActiveUserIsNotNone()

            files = self.__dialogs.getOpenFilesAndDirs(
                self._tool.gui,
                self.tr("Select files you want to add to the repository"))

            # NOTE: if len(files) == 0 (user haven't selected any files) then it is supposed that
            # an Item without file should be created.

            (self._itemsCreatedCount, self._filesSkippedCount, self.lastSavedItemIds) = \
                AddItemAlgorithms.addItems(self._tool, self.__dialogs, files)

            self._emitHandlerSignal(HandlerSignals.ITEM_CREATED)

            stats.sendEvent("items_table.add_items")

        except errors.CancelOperationError:
            return
        except Exception as ex:
            show_exc_info(self._tool.gui, ex)
        finally:
            self._emitHandlerSignal(
                HandlerSignals.STATUS_BAR_MESSAGE,
                self.tr(
                    "Operation completed. Added {}, skipped {} files.").format(
                        self._itemsCreatedCount, self._filesSkippedCount))
Пример #11
0
    def buttonMoveFile(self):
        try:
            if self.item.data_ref is None:
                raise Exception(self.tr("You must add a file first."))

            directory = QtGui.QFileDialog.getExistingDirectory(
                self, self.tr("Select destination path within repository"),
                self.repoBasePath)
            if is_none_or_empty(directory):
                return

            if not is_internal(directory, self.repoBasePath):
                raise MsgException(
                    self.tr("Chosen directory is out of active repository."))

            new_dst_path = os.path.relpath(directory, self.repoBasePath)
            if not new_dst_path.startswith("."):
                new_dst_path = os.path.join(".", new_dst_path)

            newDstRelPath = os.path.join(
                new_dst_path, os.path.basename(self.item.data_ref.url))
            self.ui.fileRelPath.setText(newDstRelPath)

        except Exception as ex:
            show_exc_info(self, ex)
    def handle(self):
        try:
            self._tool.checkActiveRepoIsNotNone()

            rows = self._tool.gui.selectedRows()
            if len(rows) == 0:
                raise errors.MsgException(
                    self.tr("There are no selected items."))

            exportFilename = self._dialogs.getSaveFileName(
                self._tool.gui, self.tr('Save results in a file.'))
            if not exportFilename:
                raise errors.MsgException(self.tr("Operation canceled."))

            with open(exportFilename, "w", newline='') as exportFile:
                for row in rows:
                    item = self._tool.gui.itemAtRow(row)
                    if not item.hasDataRef():
                        continue
                    textline = self._tool.repo.base_path + \
                        os.sep + self._tool.gui.itemAtRow(row).data_ref.url + os.linesep
                    exportFile.write(textline)

            stats.sendEvent("items_table.export_items_file_paths")

        except Exception as ex:
            show_exc_info(self._tool.gui, ex)

        else:
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                                    self.tr("Operation completed."),
                                    consts.STATUSBAR_TIMEOUT)
Пример #13
0
    def handle(self):
        try:
            self._model.checkActiveRepoIsNotNone()
            self._model.checkActiveUserIsNotNone()

            importFromFilename = self._dialogs.getOpenFileName(
                self._model.gui,
                self.tr("Open Reggata Archive File"),
                self.tr("Reggata Archive File (*.raf)"))
            if not importFromFilename:
                raise MsgException(self.tr("You haven't chosen a file. Operation canceled."))

            thread = ImportItemsThread(self, self._model.repo, importFromFilename,
                                       self._model.user.login)

            self._dialogs.startThreadWithWaitDialog(thread, self._model.gui, indeterminate=False)

            self._emitHandlerSignal(HandlerSignals.ITEM_CREATED)

            #TODO: display information about how many items were imported
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                self.tr("Operation completed."), STATUSBAR_TIMEOUT)

            stats.sendEvent("main_window.import_items")

        except Exception as ex:
            show_exc_info(self._model.gui, ex)
Пример #14
0
    def handle(self):
        logger.info("DeleteFilesActionHandler.handle invoked")
        try:
            self._tool.checkActiveRepoIsNotNone()
            self._tool.checkActiveUserIsNotNone()

            selFilesAndDirs = self._tool.gui.selectedFiles()
            selFilesAndDirs = DeleteFilesActionHandler.__filterSelectedFilesDirs(selFilesAndDirs)
            selFileAbsPaths = self.__getListOfAllAffectedFiles(selFilesAndDirs)

            thread = DeleteFilesThread(self._tool.gui, self._tool.repo, selFileAbsPaths, selFilesAndDirs)
            self._dialogs.startThreadWithWaitDialog(thread, self._tool.gui, indeterminate=False)

            if thread.errors > 0:
                self._dialogs.execMessageBox(self._tool.gui,
                                             text="There were {} errors.".format(thread.errors),
                                             detailedText=thread.detailed_message)
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE, self.tr("Done."),
                                    consts.STATUSBAR_TIMEOUT)
            self._emitHandlerSignal(HandlerSignals.ITEM_CHANGED)

            stats.sendEvent("file_browser.delete_files")

        except Exception as ex:
            show_exc_info(self._tool.gui, ex)
Пример #15
0
    def handle(self):
        try:
            self._tool.checkActiveRepoIsNotNone()

            rows = self._tool.gui.selectedRows()
            if len(rows) == 0:
                raise errors.MsgException(self.tr("There are no selected items."))

            exportFilename = self._dialogs.getSaveFileName(self._tool.gui,
                self.tr('Save results in a file.'))
            if not exportFilename:
                raise errors.MsgException(self.tr("Operation canceled."))

            with open(exportFilename, "w", newline='') as exportFile:
                for row in rows:
                    item = self._tool.gui.itemAtRow(row)
                    if not item.hasDataRef():
                        continue
                    textline = self._tool.repo.base_path + \
                        os.sep + self._tool.gui.itemAtRow(row).data_ref.url + os.linesep
                    exportFile.write(textline)

            stats.sendEvent("items_table.export_items_file_paths")

        except Exception as ex:
            show_exc_info(self._tool.gui, ex)

        else:
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                self.tr("Operation completed."), consts.STATUSBAR_TIMEOUT)
    def handle(self):
        logger.info("AddFilesToRepoActionHandler.handle invoked")
        try:
            self._tool.checkActiveRepoIsNotNone()
            self._tool.checkActiveUserIsNotNone()

            files = self._tool.gui.selectedFiles()
            if len(files) == 0:
                raise err.MsgException(self.tr("There are no selected files."))

            (self._itemsCreatedCount, self._filesSkippedCount, self.lastSavedItemIds) = \
                AddItemAlgorithms.addItems(self._tool, self._dialogs, files)

            self._emitHandlerSignal(HandlerSignals.ITEM_CREATED)

            stats.sendEvent("file_browser.add_files")

        except err.CancelOperationError:
            return
        except Exception as ex:
            show_exc_info(self._tool.gui, ex)
        finally:
            self._emitHandlerSignal(
                HandlerSignals.STATUS_BAR_MESSAGE,
                self.tr(
                    "Operation completed. Added {}, skipped {} files.").format(
                        self._itemsCreatedCount, self._filesSkippedCount))
Пример #17
0
 def button_ok(self):
     try:
         self.write()
         self.user.checkValid()
         self.accept()
     except Exception as ex:
         show_exc_info(self, ex)
    def handle(self):
        logger.info("DeleteFilesActionHandler.handle invoked")
        try:
            self._tool.checkActiveRepoIsNotNone()
            self._tool.checkActiveUserIsNotNone()

            selFilesAndDirs = self._tool.gui.selectedFiles()
            selFilesAndDirs = DeleteFilesActionHandler.__filterSelectedFilesDirs(
                selFilesAndDirs)
            selFileAbsPaths = self.__getListOfAllAffectedFiles(selFilesAndDirs)

            thread = DeleteFilesThread(self._tool.gui, self._tool.repo,
                                       selFileAbsPaths, selFilesAndDirs)
            self._dialogs.startThreadWithWaitDialog(thread,
                                                    self._tool.gui,
                                                    indeterminate=False)

            if thread.errors > 0:
                self._dialogs.execMessageBox(
                    self._tool.gui,
                    text="There were {} errors.".format(thread.errors),
                    detailedText=thread.detailed_message)
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                                    self.tr("Done."), consts.STATUSBAR_TIMEOUT)
            self._emitHandlerSignal(HandlerSignals.ITEM_CHANGED)

            stats.sendEvent("file_browser.delete_files")

        except Exception as ex:
            show_exc_info(self._tool.gui, ex)
Пример #19
0
    def handle(self):
        try:
            dialogs = UserDialogsFacade()
            basePath = dialogs.getExistingDirectory(
                self._model.gui, self.tr("Choose a repository base path"))

            if not basePath:
                raise Exception(
                    self.
                    tr("You haven't chosen existent directory. Operation canceled."
                       ))

            #QFileDialog returns forward slashes in windows! Because of this path should be normalized
            basePath = os.path.normpath(basePath)
            self._model.repo = RepoMgr(basePath)
            self._model.user = None
            self._model.loginRecentUser()

            stats.sendEvent("main_window.open_repo")

        except LoginError:
            self.__letUserLoginByHimself()

        except Exception as ex:
            show_exc_info(self._model.gui, ex)
Пример #20
0
    def handle(self):
        logger.info("OpenFileActionHandler.handle invoked")
        try:
            selFiles = self._tool.gui.selectedFiles()
            if len(selFiles) != 1:
                raise err.MsgException(self.tr("Select one file, please."))

            selFile = selFiles[0]
            assert os.path.isabs(selFiles[0]), "Path '{}' should be absolute".format(selFile)

            if os.path.isdir(selFile):
                self._extAppMgr.openContainingDirWithExtAppManager(selFile)
            elif os.path.isfile(selFile):
                self._extAppMgr.openFileWithExtApp(selFile)
            else:
                raise err.MsgException(self.tr("This is not a file and not a directory, cannot open it."))

            stats.sendEvent("file_browser.open_file")

        except Exception as ex:
            show_exc_info(self._tool.gui, ex)

        else:
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                self.tr("Done."), consts.STATUSBAR_TIMEOUT)
Пример #21
0
    def handle(self):
        logger.info("AddFilesToRepoActionHandler.handle invoked")
        try:
            self._tool.checkActiveRepoIsNotNone()
            self._tool.checkActiveUserIsNotNone()

            files = self._tool.gui.selectedFiles()
            if len(files) == 0:
                raise err.MsgException(self.tr("There are no selected files."))

            (self._itemsCreatedCount, self._filesSkippedCount, self.lastSavedItemIds) = \
                AddItemAlgorithms.addItems(self._tool, self._dialogs, files)

            self._emitHandlerSignal(HandlerSignals.ITEM_CREATED)

            stats.sendEvent("file_browser.add_files")

        except err.CancelOperationError:
            return
        except Exception as ex:
            show_exc_info(self._tool.gui, ex)
        finally:
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                self.tr("Operation completed. Added {}, skipped {} files.")
                    .format(self._itemsCreatedCount, self._filesSkippedCount))
Пример #22
0
    def handle(self):
        try:
            self._tool.checkActiveRepoIsNotNone()
            self._tool.checkActiveUserIsNotNone()

            rows = self._tool.gui.selectedRows()
            if len(rows) == 0:
                raise errors.MsgException(self.tr("There are no selected items."))

            tmpDir = UserConfig().get("tmp_dir", consts.DEFAULT_TMP_DIR)
            if not os.path.exists(tmpDir):
                os.makedirs(tmpDir)

            m3uFilename = str(os.getpid()) + self._tool.user.login + str(time.time()) + ".m3u"
            with open(os.path.join(tmpDir, m3uFilename), "wt") as m3uFile:
                for row in rows:
                    item = self._tool.gui.itemAtRow(row)
                    if item.data_ref is None:
                        continue
                    m3uFile.write(
                        os.path.join(self._tool.repo.base_path,
                                     item.data_ref.url) + os.linesep)

            self._extAppMgr.openFileWithExtApp(os.path.join(tmpDir, m3uFilename))

            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                self.tr("Done."), consts.STATUSBAR_TIMEOUT)

            stats.sendEvent("items_table.export_items_to_m3u_and_open_it")

        except Exception as ex:
            show_exc_info(self._tool.gui, ex)
    def handle(self):
        try:
            self._tool.checkActiveRepoIsNotNone()
            self._tool.checkActiveUserIsNotNone()

            rows = self._tool.gui.selectedRows()
            if len(rows) == 0:
                raise errors.MsgException(
                    self.tr("There are no selected items."))

            tmpDir = UserConfig().get("tmp_dir", consts.DEFAULT_TMP_DIR)
            if not os.path.exists(tmpDir):
                os.makedirs(tmpDir)

            m3uFilename = str(os.getpid()) + self._tool.user.login + str(
                time.time()) + ".m3u"
            with open(os.path.join(tmpDir, m3uFilename), "wt") as m3uFile:
                for row in rows:
                    item = self._tool.gui.itemAtRow(row)
                    if item.data_ref is None:
                        continue
                    m3uFile.write(
                        os.path.join(self._tool.repo.base_path,
                                     item.data_ref.url) + os.linesep)

            self._extAppMgr.openFileWithExtApp(
                os.path.join(tmpDir, m3uFilename))

            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                                    self.tr("Done."), consts.STATUSBAR_TIMEOUT)

            stats.sendEvent("items_table.export_items_to_m3u_and_open_it")

        except Exception as ex:
            show_exc_info(self._tool.gui, ex)
    def handle(self):
        try:
            selRows = self._tool.gui.selectedRows()
            if len(selRows) != 1:
                raise errors.MsgException(self.tr("Select one item, please."))

            dataRef = self._tool.gui.itemAtRow(selRows.pop()).data_ref

            if dataRef is None or dataRef.type != db.DataRef.FILE:
                raise errors.MsgException(
                    self.
                    tr("This action can be applied only to the items linked with files."
                       ))

            self._extAppMgr.openFileWithExtApp(
                os.path.join(self._tool.repo.base_path, dataRef.url))

            stats.sendEvent("items_table.open_item")

        except Exception as ex:
            show_exc_info(self._tool.gui, ex)

        else:
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                                    self.tr("Done."), consts.STATUSBAR_TIMEOUT)
Пример #25
0
    def handle(self):
        try:
            self._model.checkActiveRepoIsNotNone()
            self._model.checkActiveUserIsNotNone()

            user = self._model.user

            dialogs = UserDialogsFacade()
            dialogExecOk, newPasswordHash = \
                dialogs.execChangeUserPasswordDialog(user=user, gui=self._model.gui)
            if not dialogExecOk:
                return

            uow = self._model.repo.createUnitOfWork()
            try:
                command = ChangeUserPasswordCommand(user.login, newPasswordHash)
                uow.executeCommand(command)
            finally:
                uow.close()

            user.password = newPasswordHash

            stats.sendEvent("main_window.change_user_password")

        except Exception as ex:
            show_exc_info(self._model.gui, ex)
        else:
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                self.tr("Operation completed."), STATUSBAR_TIMEOUT)
Пример #26
0
    def handle(self):
        try:
            self._model.checkActiveRepoIsNotNone()
            self._model.checkActiveUserIsNotNone()

            user = self._model.user

            dialogs = UserDialogsFacade()
            dialogExecOk, newPasswordHash = \
                dialogs.execChangeUserPasswordDialog(user=user, gui=self._model.gui)
            if not dialogExecOk:
                return

            uow = self._model.repo.createUnitOfWork()
            try:
                command = ChangeUserPasswordCommand(user.login,
                                                    newPasswordHash)
                uow.executeCommand(command)
            finally:
                uow.close()

            user.password = newPasswordHash

            stats.sendEvent("main_window.change_user_password")

        except Exception as ex:
            show_exc_info(self._model.gui, ex)
        else:
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                                    self.tr("Operation completed."),
                                    STATUSBAR_TIMEOUT)
Пример #27
0
    def handle(self):
        try:
            action = self.sender()
            repoBasePath = action.repoBasePath

            currentUser = self._model.user
            assert currentUser is not None

            self._model.repo = RepoMgr(repoBasePath)

            try:
                self._model.loginUser(currentUser.login, currentUser.password)
                self._emitHandlerSignal(
                    HandlerSignals.STATUS_BAR_MESSAGE,
                    self.tr("Repository opened. Login succeded."),
                    STATUSBAR_TIMEOUT)

            except LoginError:
                self._model.user = None
                self._emitHandlerSignal(
                    HandlerSignals.STATUS_BAR_MESSAGE,
                    self.tr("Repository opened. Login failed."),
                    STATUSBAR_TIMEOUT)

            stats.sendEvent("main_window.open_favorite_repo")

        except Exception as ex:
            show_exc_info(self._model.gui, ex)
Пример #28
0
    def buttonOk(self):
        try:
            self.write()
            self.checkThatCurrentPasswordIsCorrect()
            self.checkThatTwoNewPasswordsAreTheSame()
            self.accept()

        except Exception as ex:
            helpers.show_exc_info(self, ex)
Пример #29
0
    def buttonOk(self):
        try:
            self.write()
            self.checkThatCurrentPasswordIsCorrect()
            self.checkThatTwoNewPasswordsAreTheSame()
            self.accept()

        except Exception as ex:
            helpers.show_exc_info(self, ex)
Пример #30
0
    def handle(self):
        try:
            self._model.checkActiveRepoIsNotNone()
            self._model.repo = None
            self._model.user = None

            stats.sendEvent("main_window.close_repo")

        except Exception as ex:
            show_exc_info(self._model.gui, ex)
Пример #31
0
    def handle(self):
        try:
            self._model.checkActiveRepoIsNotNone()
            self._model.repo = None
            self._model.user = None

            stats.sendEvent("main_window.close_repo")

        except Exception as ex:
            show_exc_info(self._model.gui, ex)
Пример #32
0
 def handle(self):
     try:
         ad = AboutDialog(self._model.gui)
         ad.exec_()
         stats.sendEvent("main_window.show_about_dialog")
     except Exception as ex:
         show_exc_info(self._model.gui, ex)
     else:
         self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
             self.tr("Operation completed."), STATUSBAR_TIMEOUT)
Пример #33
0
    def action_prev(self):
        try:
            self.i_current -= 1
            if self.i_current < 0:
                self.i_current = len(self.items) - 1

            self.__renderCurrentItemFile()

        except Exception as ex:
            show_exc_info(self, ex)
Пример #34
0
 def __letUserLoginByHimself(self):
     user = User()
     dialogs = UserDialogsFacade()
     if not dialogs.execUserDialog(
         user=user, gui=self._model.gui, dialogMode=UserDialog.LOGIN_MODE):
         return
     try:
         self._model.loginUser(user.login, user.password)
     except Exception as ex:
         show_exc_info(self._model.gui, ex)
Пример #35
0
    def action_next(self):
        try:
            self.i_current += 1
            if self.i_current >= len(self.items):
                self.i_current = 0

            self.__renderCurrentItemFile()

        except Exception as ex:
            show_exc_info(self, ex)
Пример #36
0
    def action_prev(self):
        try:
            self.i_current -= 1
            if self.i_current < 0:
                self.i_current = len(self.items) - 1

            self.__renderCurrentItemFile()

        except Exception as ex:
            show_exc_info(self, ex)
Пример #37
0
    def action_next(self):
        try:
            self.i_current += 1
            if self.i_current >= len(self.items):
                self.i_current = 0

            self.__renderCurrentItemFile()

        except Exception as ex:
            show_exc_info(self, ex)
Пример #38
0
 def handle(self):
     try:
         ad = AboutDialog(self._model.gui)
         ad.exec_()
         stats.sendEvent("main_window.show_about_dialog")
     except Exception as ex:
         show_exc_info(self._model.gui, ex)
     else:
         self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                                 self.tr("Operation completed."),
                                 STATUSBAR_TIMEOUT)
Пример #39
0
 def __letUserLoginByHimself(self):
     user = User()
     dialogs = UserDialogsFacade()
     if not dialogs.execUserDialog(user=user,
                                   gui=self._model.gui,
                                   dialogMode=UserDialog.LOGIN_MODE):
         return
     try:
         self._model.loginUser(user.login, user.password)
     except Exception as ex:
         show_exc_info(self._model.gui, ex)
Пример #40
0
    def __writeFileBrowserCommand(self):
        currentCmd = self.__extAppMgrState.extFileMgrCommandPattern
        try:
            userText = self.ui.lineEditExtFileBrowserCmd.text().strip()
            if helpers.is_none_or_empty(userText):
                raise MsgException(self.tr("File Browser command should not be empty."))

            self.__extAppMgrState.extFileMgrCommandPattern = userText

        except Exception as ex:
            helpers.show_exc_info(self, ex)
            self.ui.lineEditExtFileBrowserCmd.setText(currentCmd)
    def handle(self):
        def refresh(percent, row):
            self._emitHandlerSignal(
                HandlerSignals.STATUS_BAR_MESSAGE,
                self.tr("Rebuilding thumbnails ({0}%)").format(percent))
            self._emitHandlerSignal(HandlerSignals.RESET_SINGLE_ROW, row)
            QtCore.QCoreApplication.processEvents()

        try:
            self._tool.checkActiveRepoIsNotNone()
            self._tool.checkActiveUserIsNotNone()

            rows = self._tool.gui.selectedRows()
            if len(rows) == 0:
                raise errors.MsgException(
                    self.tr("There are no selected items."))

            uow = self._tool.repo.createUnitOfWork()
            try:
                items = []
                for row in rows:
                    item = self._tool.gui.itemAtRow(row)
                    item.table_row = row
                    items.append(item)

                thread = threads.ThumbnailBuilderThread(self._tool.gui,
                                                        self._tool.repo,
                                                        items,
                                                        self._tool.itemsLock,
                                                        rebuild=True)

                self.connect(
                    thread, QtCore.SIGNAL("exception"), lambda exc_info:
                    show_exc_info(self._tool.gui,
                                  exc_info[1],
                                  details=format_exc_info(*exc_info)))
                self.connect(thread, QtCore.SIGNAL("progress"),
                             lambda percents, row: refresh(percents, row))
                self.connect(
                    thread, QtCore.SIGNAL("finished"),
                    lambda: self._emitHandlerSignal(
                        HandlerSignals.STATUS_BAR_MESSAGE,
                        self.tr("Rebuild thumbnails is done.")))
                thread.start()

            finally:
                uow.close()

            stats.sendEvent("items_table.rebuild_item_thumbnail")

        except Exception as ex:
            show_exc_info(self._tool.gui, ex)
Пример #42
0
    def action_edit_item(self):
        try:
            self.__checkActiveRepoIsNotNone()
            self.__checkActiveUserIsNotNone()

            itemId = self.items[self.i_current].id
            self.__editSingleItem(itemId)

        except Exception as ex:
            show_exc_info(self, ex)
        else:
            # TODO: pass some item id so widgets could update only edited item
            self.emit(QtCore.SIGNAL("handlerSignal"), HandlerSignals.ITEM_CHANGED)
Пример #43
0
    def action_edit_item(self):
        try:
            self.__checkActiveRepoIsNotNone()
            self.__checkActiveUserIsNotNone()

            itemId = self.items[self.i_current].id
            self.__editSingleItem(itemId)

        except Exception as ex:
            show_exc_info(self, ex)
        else:
            # TODO: pass some item id so widgets could update only edited item
            self.emit(QtCore.SIGNAL("handlerSignal"),
                      HandlerSignals.ITEM_CHANGED)
    def handle(self):
        try:
            self._tool.checkActiveRepoIsNotNone()
            self._tool.checkActiveUserIsNotNone()

            itemIds = self._tool.gui.selectedItemIds()
            if len(itemIds) == 0:
                raise errors.MsgException(
                    self.tr("There are no selected items."))

            mbResult = self._dialogs.execMessageBox(
                self._tool.gui,
                text=self.
                tr("Do you really want to delete {} selected file(s)?").format(
                    len(itemIds)),
                buttons=[QtGui.QMessageBox.Yes, QtGui.QMessageBox.No])
            if mbResult != QtGui.QMessageBox.Yes:
                raise errors.CancelOperationError()

            thread = threads.DeleteGroupOfItemsThread(self._tool.gui,
                                                      self._tool.repo, itemIds,
                                                      self._tool.user.login)

            self._dialogs.startThreadWithWaitDialog(thread,
                                                    self._tool.gui,
                                                    indeterminate=False)

            if thread.errors > 0:
                self._dialogs.execMessageBox(
                    self._tool.gui,
                    text=self.tr("There were {0} errors.").format(
                        thread.errors),
                    detailedText=thread.detailed_message)

            stats.sendEvent("items_table.delete_item")

        except errors.CancelOperationError:
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                                    self.tr("Operation cancelled."),
                                    consts.STATUSBAR_TIMEOUT)

        except Exception as ex:
            show_exc_info(self._tool.gui, ex)

        else:
            #TODO: display information about how many items were deleted
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                                    self.tr("Operation completed."),
                                    consts.STATUSBAR_TIMEOUT)
            self._emitHandlerSignal(HandlerSignals.ITEM_DELETED)
    def handle(self):
        logger.info("MoveFilesActionHandler.handle invoked")
        try:
            self._tool.checkActiveRepoIsNotNone()
            self._tool.checkActiveUserIsNotNone()

            selFilesAndDirs = self._tool.gui.selectedFiles()
            selFilesAndDirs = MoveFilesActionHandler.__filterSelectedFilesDirs(
                selFilesAndDirs)
            selFileAbsPaths = self.__getListOfAllAffectedFiles(selFilesAndDirs)

            if len(selFileAbsPaths) == 0:
                return

            dstDir = self._dialogs.getExistingDirectory(
                self._tool.gui, self.tr("Select destination directory"))
            if not dstDir:
                return

            if not hlp.is_internal(dstDir, self._tool.repo.base_path):
                raise err.WrongValueError(
                    self.
                    tr("Selected directory should be within the current repo"))

            dstFileAbsPaths = []
            currDir = self._tool.currDir
            for absFile in selFileAbsPaths:
                relFile = os.path.relpath(absFile, currDir)
                dstAbsFile = os.path.join(dstDir, relFile)
                dstFileAbsPaths.append((absFile, dstAbsFile))

            thread = MoveFilesThread(self._tool.gui, self._tool.repo,
                                     dstFileAbsPaths, selFilesAndDirs)
            self._dialogs.startThreadWithWaitDialog(thread,
                                                    self._tool.gui,
                                                    indeterminate=False)

            if thread.errors > 0:
                self._dialogs.execMessageBox(
                    self._tool.gui,
                    text="There were {} errors.".format(thread.errors),
                    detailedText=thread.detailed_message)
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                                    self.tr("Done."), consts.STATUSBAR_TIMEOUT)
            self._emitHandlerSignal(HandlerSignals.ITEM_CHANGED)

            stats.sendEvent("file_browser.move_files")

        except Exception as ex:
            show_exc_info(self._tool.gui, ex)
    def handle(self):
        try:
            self._tool.checkActiveRepoIsNotNone()

            itemIds = self._tool.gui.selectedItemIds()
            if len(itemIds) == 0:
                raise errors.MsgException(
                    self.tr("There are no selected items."))

            exportFilename = self._dialogs.getSaveFileName(
                self._tool.gui, self.tr('Save data as..'),
                self.tr("Reggata Archive File (*.raf)"))
            if not exportFilename:
                raise errors.MsgException(
                    self.tr("You haven't chosen a file. Operation canceled."))

            if not exportFilename.endswith(".raf"):
                exportFilename += ".raf"

            if os.path.exists(exportFilename):
                mbRes = self._dialogs.execMessageBox(
                    self._tool.gui,
                    text=self.tr(
                        "File {} already exists. Do you want to overwrite it?"
                    ).format(exportFilename),
                    buttons=[QtGui.QMessageBox.Yes | QtGui.QMessageBox.No])
                if mbRes != QtGui.QMessageBox.Yes:
                    return

            thread = threads.ExportItemsThread(self, self._tool.repo, itemIds,
                                               exportFilename)

            self._dialogs.startThreadWithWaitDialog(thread,
                                                    self._tool.gui,
                                                    indeterminate=False)

            self._exported = thread.exportedCount
            self._skipped = thread.skippedCount

            stats.sendEvent("items_table.export_items")

        except Exception as ex:
            show_exc_info(self._tool.gui, ex)

        else:
            self._emitHandlerSignal(
                HandlerSignals.STATUS_BAR_MESSAGE,
                self.tr("Operation completed. Exported {}, skipped {} items.").
                format(self._exported, self._skipped))
Пример #47
0
    def button_ok(self):
        try:
            if self.mode == ItemDialog.VIEW_MODE:
                self.accept()

            elif self.mode == ItemDialog.CREATE_MODE or self.mode == ItemDialog.EDIT_MODE:
                self.write()
                self.item.checkValid()
                self.accept()

            else:
                raise ValueError(self.tr("self.mode has bad value."))

        except Exception as ex:
            show_exc_info(self, ex)
Пример #48
0
    def button_ok(self):
        try:
            if self.mode == ItemDialog.VIEW_MODE:
                self.accept()

            elif self.mode == ItemDialog.CREATE_MODE or self.mode == ItemDialog.EDIT_MODE:
                self.write()
                self.item.checkValid()
                self.accept()

            else:
                raise ValueError(self.tr("self.mode has bad value."))

        except Exception as ex:
            show_exc_info(self, ex)
Пример #49
0
    def __writeApplicationCommand(self):
        index = self.__currentCategoryIndex()
        if index < 0:
            return
        currentAppCmd = self.__extAppMgrState.appDescriptions[index].appCommandPattern

        try:
            userText = self.ui.lineEditAppCmd.text().strip()
            if helpers.is_none_or_empty(userText):
                raise MsgException(self.tr("Application command should not be empty."))

            self.__extAppMgrState.appDescriptions[index].appCommandPattern = userText

        except Exception as ex:
            helpers.show_exc_info(self, ex)
            self.ui.lineEditAppCmd.setText(currentAppCmd)
Пример #50
0
    def handle(self):
        try:
            extAppMgrState = ExtAppMgr.readCurrentState()
            dialog = ExternalAppsDialog(self._model.gui, extAppMgrState, self._dialogs)
            if dialog.exec_() != QtGui.QDialog.Accepted:
                return

            ExtAppMgr.setCurrentState(dialog.extAppMgrState())
            self._emitHandlerSignal(HandlerSignals.REGGATA_CONF_CHANGED)
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                self.tr("Operation completed."), STATUSBAR_TIMEOUT)

            stats.sendEvent("main_window.manage_external_apps")

        except Exception as ex:
            show_exc_info(self._model.gui, ex)
Пример #51
0
    def handle(self):
        try:
            self._model.checkActiveRepoIsNotNone()

            user = User()

            dialogs = UserDialogsFacade()
            if not dialogs.execUserDialog(
                user=user, gui=self._model.gui, dialogMode=UserDialog.LOGIN_MODE):
                return

            self._model.loginUser(user.login, user.password)

            stats.sendEvent("main_window.login_user")

        except Exception as ex:
            show_exc_info(self._model.gui, ex)
Пример #52
0
    def handle(self):

        def refresh(percent, row):
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                self.tr("Rebuilding thumbnails ({0}%)").format(percent))
            self._emitHandlerSignal(HandlerSignals.RESET_SINGLE_ROW, row)
            QtCore.QCoreApplication.processEvents()

        try:
            self._tool.checkActiveRepoIsNotNone()
            self._tool.checkActiveUserIsNotNone()

            rows = self._tool.gui.selectedRows()
            if len(rows) == 0:
                raise errors.MsgException(self.tr("There are no selected items."))


            uow = self._tool.repo.createUnitOfWork()
            try:
                items = []
                for row in rows:
                    item = self._tool.gui.itemAtRow(row)
                    item.table_row = row
                    items.append(item)

                thread = threads.ThumbnailBuilderThread(
                    self._tool.gui, self._tool.repo, items, self._tool.itemsLock,
                    rebuild=True)

                self.connect(thread, QtCore.SIGNAL("exception"),
                    lambda exc_info: show_exc_info(
                        self._tool.gui, exc_info[1], details=format_exc_info(*exc_info)))
                self.connect(thread, QtCore.SIGNAL("progress"),
                    lambda percents, row: refresh(percents, row))
                self.connect(thread, QtCore.SIGNAL("finished"),
                    lambda: self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                        self.tr("Rebuild thumbnails is done.")))
                thread.start()

            finally:
                uow.close()

            stats.sendEvent("items_table.rebuild_item_thumbnail")

        except Exception as ex:
            show_exc_info(self._tool.gui, ex)
Пример #53
0
    def handle(self):
        try:
            self._model.checkActiveRepoIsNotNone()
            self._model.checkActiveUserIsNotNone()

            repoBasePath = self._model.repo.base_path
            userLogin = self._model.user.login

            self.__favoriteReposStorage.removeRepoFromFavorites(userLogin, repoBasePath)

            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                self.tr("Current repository removed from favorites list."), STATUSBAR_TIMEOUT)
            self._emitHandlerSignal(HandlerSignals.LIST_OF_FAVORITE_REPOS_CHANGED)

            stats.sendEvent("main_window.remove_repo_from_favorites")

        except Exception as ex:
            show_exc_info(self._model.gui, ex)
Пример #54
0
 def _and_not_tag(self):
     '''
         Adds a tag negation (NOT Tag) to the query (from context menu).
     '''
     try:
         sel_text = self.textCursor().selectedText()
         if not sel_text:
             sel_text = self.word
         if not sel_text:
             raise MsgException(self.tr("There is no selected text in tag cloud."))
         if parsers.query_tokens.needs_quote(sel_text):
             sel_text = parsers.util.quote(sel_text)
         self.not_tags.add(sel_text)
         self.emit(QtCore.SIGNAL("selectedTagsChanged"), self.tags, self.not_tags)
         self.refresh()
         stats.sendEvent("tag_cloud.ctx_menu.and_not_tag")
     except Exception as ex:
         show_exc_info(self, ex)
Пример #55
0
    def query_exec(self):
        try:
            if self.__table_model is None:
                raise errors.MsgException(self.tr("Items Table Widget has no Model."))

            query_text = self.query_text()
            limit = self.query_limit()
            page = self.query_page()

            self.__table_model.query(query_text, limit, page)

            self.resize_rows_to_contents()

            stats.sendEvent("items_table.query_exec")


        except Exception as ex:
            logger.warning(str(ex))
            helpers.show_exc_info(self, ex)
Пример #56
0
    def handle(self):
        logger.info("MoveFilesActionHandler.handle invoked")
        try:
            self._tool.checkActiveRepoIsNotNone()
            self._tool.checkActiveUserIsNotNone()

            selFilesAndDirs = self._tool.gui.selectedFiles()
            selFilesAndDirs = MoveFilesActionHandler.__filterSelectedFilesDirs(selFilesAndDirs)
            selFileAbsPaths = self.__getListOfAllAffectedFiles(selFilesAndDirs)

            if len(selFileAbsPaths) == 0:
                return

            dstDir = self._dialogs.getExistingDirectory(self._tool.gui, self.tr("Select destination directory"))
            if not dstDir:
                return

            if not hlp.is_internal(dstDir, self._tool.repo.base_path):
                raise err.WrongValueError(self.tr("Selected directory should be within the current repo"))

            dstFileAbsPaths = []
            currDir = self._tool.currDir
            for absFile in selFileAbsPaths:
                relFile = os.path.relpath(absFile, currDir)
                dstAbsFile = os.path.join(dstDir, relFile)
                dstFileAbsPaths.append((absFile, dstAbsFile))

            thread = MoveFilesThread(self._tool.gui, self._tool.repo, dstFileAbsPaths, selFilesAndDirs)
            self._dialogs.startThreadWithWaitDialog(thread, self._tool.gui, indeterminate=False)

            if thread.errors > 0:
                self._dialogs.execMessageBox(self._tool.gui,
                                             text="There were {} errors.".format(thread.errors),
                                             detailedText=thread.detailed_message)
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE, self.tr("Done."),
                                consts.STATUSBAR_TIMEOUT)
            self._emitHandlerSignal(HandlerSignals.ITEM_CHANGED)

            stats.sendEvent("file_browser.move_files")

        except Exception as ex:
            show_exc_info(self._tool.gui, ex)
Пример #57
0
    def handle(self):
        try:
            self._tool.checkActiveRepoIsNotNone()

            itemIds = self._tool.gui.selectedItemIds()
            if len(itemIds) == 0:
                raise errors.MsgException(self.tr("There are no selected items."))

            exportFilename = self._dialogs.getSaveFileName(
                self._tool.gui,
                self.tr('Save data as..'),
                self.tr("Reggata Archive File (*.raf)"))
            if not exportFilename:
                raise errors.MsgException(self.tr("You haven't chosen a file. Operation canceled."))

            if not exportFilename.endswith(".raf"):
                exportFilename += ".raf"

            if os.path.exists(exportFilename):
                mbRes = self._dialogs.execMessageBox(self._tool.gui,
                                             text=self.tr("File {} already exists. Do you want to overwrite it?")
                                             .format(exportFilename),
                                             buttons=[QtGui.QMessageBox.Yes | QtGui.QMessageBox.No])
                if mbRes != QtGui.QMessageBox.Yes:
                    return

            thread = threads.ExportItemsThread(self, self._tool.repo, itemIds, exportFilename)

            self._dialogs.startThreadWithWaitDialog(thread, self._tool.gui, indeterminate=False)

            self._exported = thread.exportedCount
            self._skipped = thread.skippedCount

            stats.sendEvent("items_table.export_items")

        except Exception as ex:
            show_exc_info(self._tool.gui, ex)

        else:
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                self.tr("Operation completed. Exported {}, skipped {} items.")
                .format(self._exported, self._skipped))
Пример #58
0
    def handle(self):
        try:
            self._tool.checkActiveRepoIsNotNone()
            self._tool.checkActiveUserIsNotNone()

            itemIds = self._tool.gui.selectedItemIds()
            if len(itemIds) == 0:
                raise err.MsgException(self.tr("There are no selected items."))

            if len(itemIds) > 1:
                updated, skipped = self.__editManyItems(itemIds)
            else:
                updated, skipped = self.__editSingleItem(itemIds.pop())

            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                self.tr("Editing done. Updated={}, skipped={} items.".format(updated, skipped)))
            self._emitHandlerSignal(HandlerSignals.ITEM_CHANGED)

        except Exception as ex:
            hlp.show_exc_info(self._tool.gui, ex)
Пример #59
0
    def handle(self):
        try:
            selRows = self._tool.gui.selectedRows()
            if len(selRows) != 1:
                raise errors.MsgException(self.tr("Select one item, please."))

            dataRef = self._tool.gui.itemAtRow(selRows.pop()).data_ref

            if dataRef is None or dataRef.type != db.DataRef.FILE:
                raise errors.MsgException(
                    self.tr("This action can be applied only to the items linked with files."))


            self._extAppMgr.openContainingDirWithExtAppManager(
                os.path.join(self._tool.repo.base_path, dataRef.url))

            stats.sendEvent("items_table.open_item_with_ext_file_manager")

        except Exception as ex:
            show_exc_info(self._tool.gui, ex)