예제 #1
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)
예제 #2
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)
예제 #3
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)))
예제 #4
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)
예제 #5
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)
예제 #6
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)
예제 #7
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)
예제 #8
0
파일: main.py 프로젝트: kotnik/reggata
def main():
    startTime = datetime.now()
    configureConfigDir()
    configureTmpDir()
    configureLogging()

    logger.info("========= Reggata started =========")
    logger.debug("pyqt_version = {}".format(QtCore.PYQT_VERSION_STR))
    logger.debug("qt_version = {}".format(QtCore.QT_VERSION_STR))
    logger.debug("current dir is " + os.path.abspath("."))

    app = QApplication(sys.argv)
    configureTranslations(app)

    mw = MainWindow()
    mw.show()

    if not stats.isReggataInstanceRegistered() and not stats.isUserGaveTheAnswerAboutSendStatistics():
        askUserAboutSendStatistics(mw)

    if stats.isSendStatisticsAllowed() and not stats.isReggataInstanceRegistered():
        stats.registerReggataInstance()
        time.sleep(1)

    stats.sendEvent("reggata_started")

    app.exec_()
    logger.info("========= Reggata finished =========")

    endTime = datetime.now()
    reggataRunningTimeSec = round((endTime - startTime).total_seconds())
    stats.sendIntValue("reggata_running_time_sec", reggataRunningTimeSec)
    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)
예제 #10
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))
예제 #11
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))
예제 #12
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)
예제 #13
0
 def _onSetLimitActionTriggered(self):
     i, ok = QtGui.QInputDialog.getInteger(self, self.tr("Reggata input dialog"), \
         self.tr("Enter new value for maximum number of tags in the cloud (0 - unlimited)."), \
         value=self.limit, min=0, max=1000000000)
     if ok:
         self.limit = i
         UserConfig().store("tag_cloud.limit", i)
     stats.sendEvent("tag_cloud.ctx_menu.set_limit")
예제 #14
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)
예제 #15
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)
    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))
예제 #19
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)
    def handle(self):
        def refresh(percent, row):
            self._emitHandlerSignal(
                HandlerSignals.STATUS_BAR_MESSAGE,
                self.tr("Integrity fix {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."))

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

            thread = threads.ItemIntegrityFixerThread(self._tool.gui,
                                                      self._tool.repo, items,
                                                      self._tool.itemsLock,
                                                      self.__strategy,
                                                      self._tool.user.login)

            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("Integrity fixing is done.")))
            self.connect(
                thread, QtCore.SIGNAL("exception"), lambda exc_info:
                show_exc_info(self._tool.gui,
                              exc_info[1],
                              details=format_exc_info(*exc_info)))
            thread.start()

            stats.sendEvent("items_table.fix_item_integrity_error")

        except Exception as ex:
            show_exc_info(self._tool.gui, ex)
예제 #21
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)
예제 #22
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)
예제 #23
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)
예제 #24
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)
예제 #25
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)
예제 #26
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)
예제 #27
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)
예제 #28
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)
    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)
예제 #30
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))
    def handle(self):
        logger.info("RenameFileActionHandler.handle invoked")
        try:
            self._tool.checkActiveRepoIsNotNone()
            self._tool.checkActiveUserIsNotNone()

            selFiles = self._tool.gui.selectedFiles()
            if len(selFiles) != 1:
                raise err.MsgException(
                    self.tr("Please select one file or directory"))

            selFile = selFiles[0]

            newName, isOk = self._dialogs.execGetTextDialog(
                self._tool.gui, self.tr("Rename File"),
                self.tr("Enter new file name:"), os.path.basename(selFile))

            if not isOk or newName == os.path.basename(selFile):
                return

            if is_none_or_empty(newName.strip()):
                raise err.MsgException(
                    self.tr("Wrong input, file name cannot be empty."))

            if os.path.isdir(selFile):
                self.__renameDir(selFile, newName)
            elif os.path.isfile(selFile):
                self.__renameFile(selFile, newName)
            else:
                raise err.MsgException(
                    self.
                    tr("Cannot rename '{}' because it is not a file or directory."
                       .format(selFile)))

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

            stats.sendEvent("file_browser.rename_file")

        except Exception as ex:
            show_exc_info(self._tool.gui, ex)
예제 #32
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)
예제 #33
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)
예제 #34
0
    def handle(self):
        try:
            dialogs = UserDialogsFacade()
            basePath = dialogs.getExistingDirectory(
                self._model.gui, self.tr("Choose a base path for new repository"))

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

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

            stats.sendEvent("main_window.create_repo")

        except Exception as ex:
            show_exc_info(self._model.gui, ex)
예제 #35
0
    def mouseDoubleClickEvent(self, e):
        if self.keywordAll:
            self.emit(QtCore.SIGNAL("selectedKeywordAll"))
            self.refresh()
            stats.sendEvent("tag_cloud.all_clicked")
            return

        if not is_none_or_empty(self.word):
            word = self.word
            if parsers.query_tokens.needs_quote(word):
                word = parsers.util.quote(word)

            if e.modifiers() == Qt.ControlModifier:
                self.not_tags.add(word)
            else:
                self.tags.add(word)
            self.emit(QtCore.SIGNAL("selectedTagsChanged"), self.tags, self.not_tags)
            self.refresh()
            stats.sendEvent("tag_cloud.tag_clicked")
            return
예제 #36
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)
    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)
예제 #38
0
    def mouseDoubleClickEvent(self, e):
        if self.keywordAll:
            self.emit(QtCore.SIGNAL("selectedKeywordAll"))
            self.refresh()
            stats.sendEvent("tag_cloud.all_clicked")
            return

        if not is_none_or_empty(self.word):
            word = self.word
            if parsers.query_tokens.needs_quote(word):
                word = parsers.util.quote(word)

            if e.modifiers() == Qt.ControlModifier:
                self.not_tags.add(word)
            else:
                self.tags.add(word)
            self.emit(QtCore.SIGNAL("selectedTagsChanged"), self.tags,
                      self.not_tags)
            self.refresh()
            stats.sendEvent("tag_cloud.tag_clicked")
            return
예제 #39
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.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)
예제 #40
0
    def handle(self):
        try:
            self._model.checkActiveRepoIsNotNone()
            self._model.checkActiveUserIsNotNone()

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

            #TODO: Maybe ask user for a repoAlias...
            self.__favoriteReposStorage.addRepoToFavorites(userLogin,
                                                           repoBasePath,
                                                           os.path.basename(repoBasePath))

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

            stats.sendEvent("main_window.add_repo_to_favorites")

        except Exception as ex:
            show_exc_info(self._model.gui, ex)
예제 #41
0
    def handle(self):

        def refresh(percent, row):
            self._emitHandlerSignal(HandlerSignals.STATUS_BAR_MESSAGE,
                self.tr("Integrity fix {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."))

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

            thread = threads.ItemIntegrityFixerThread(
                self._tool.gui, self._tool.repo, items, self._tool.itemsLock, self.__strategy, self._tool.user.login)

            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("Integrity fixing is done.")))
            self.connect(thread, QtCore.SIGNAL("exception"),
                         lambda exc_info: show_exc_info(self._tool.gui, exc_info[1],
                                                        details=format_exc_info(*exc_info)))
            thread.start()

            stats.sendEvent("items_table.fix_item_integrity_error")

        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."))

            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)))
예제 #43
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)
예제 #44
0
    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)
예제 #45
0
    def handle(self):
        try:
            self._model.checkActiveRepoIsNotNone()

            user = User()

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

            uow = self._model.repo.createUnitOfWork()
            try:
                uow.executeCommand(SaveNewUserCommand(user))
                self._model.user = user
            finally:
                uow.close()

            stats.sendEvent("main_window.create_user")

        except Exception as ex:
            show_exc_info(self._model.gui, ex)
예제 #46
0
    def handle(self):
        try:
            dialogs = UserDialogsFacade()
            basePath = dialogs.getExistingDirectory(
                self._model.gui,
                self.tr("Choose a base path for new repository"))

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

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

            stats.sendEvent("main_window.create_repo")

        except Exception as ex:
            show_exc_info(self._model.gui, ex)
예제 #47
0
    def handle(self):
        try:
            self._model.checkActiveRepoIsNotNone()
            self._model.checkActiveUserIsNotNone()

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

            #TODO: Maybe ask user for a repoAlias...
            self.__favoriteReposStorage.addRepoToFavorites(
                userLogin, repoBasePath, os.path.basename(repoBasePath))

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

            stats.sendEvent("main_window.add_repo_to_favorites")

        except Exception as ex:
            show_exc_info(self._model.gui, ex)
예제 #48
0
 def handle(self):
     try:
         self._model.user = None
         stats.sendEvent("main_window.logout_user")
     except Exception as ex:
         show_exc_info(self._model.gui, ex)
예제 #49
0
 def handle(self):
     try:
         self._tool.gui.close()
         stats.sendEvent("main_window.exit_reggata")
     except Exception as ex:
         show_exc_info(self._tool.gui, ex)
 def handle(self):
     super(EditItemsActionHandlerFileBrowser, self).handle()
     stats.sendEvent("file_browser.edit_items")
예제 #51
0
 def query_reset(self):
     if self.__table_model is not None:
         self.__table_model.query("")
     self.query_text_reset()
     self.emit(QtCore.SIGNAL("queryTextResetted"))
     stats.sendEvent("items_table.query_reset")
 def handle(self):
     super(EditItemsActionHandlerItemsTable, self).handle()
     stats.sendEvent("items_table.edit_items")