示例#1
0
    def _updateStatistics(self):
        self._setHtml(_(u"Collecting statistics. Please wait..."))

        runner = LongProcessRunner(self._getContent,
                                   self,
                                   _(u"Statistics"),
                                   _(u"Collecting statistics..."))

        resultList = runner.run()
        self._setHtml(resultList)
示例#2
0
    def checkForUpdates(self):
        """
        Execute updates checking and show dialog with the results.
        """
        setStatusText(_(u"Check for new versions..."))

        progressRunner = LongProcessRunner(
            self._threadFunc,
            self._application.mainWindow,
            dialogTitle=u"UpdateNotifier",
            dialogText=_(u"Check for new versions..."))

        progressRunner.run(self._updateUrls.copy(), silenceMode=False)
示例#3
0
    def _updateStatistics(self):
        # Шаманство, связанное с тем, что HTML-рендер ожидает,
        # что есть выбранная страница
        if self._htmlRender.page is None:
            self._setHtml(_(u"A tree has no pages"))
            return

        self._setHtml(_(u"Collecting statistics. Please wait..."))

        runner = LongProcessRunner(self._getContent, self, _(u"Statistics"),
                                   _(u"Collecting statistics..."))

        resultList = runner.run()
        self._setHtml(resultList)
示例#4
0
    def checkForUpdates(self):
        """
        Execute updates checking and show dialog with the results.
        """
        setStatusText(_(u"Check for new versions..."))

        progressRunner = LongProcessRunner(
            self._threadFunc,
            self._application.mainWindow,
            dialogTitle=u"UpdateNotifier",
            dialogText=_(u"Check for new versions..."))

        progressRunner.run(self._updateUrls.copy(),
                           silenceMode=False)
示例#5
0
def openWiki(path: str, readonly: bool = False) -> Optional[WikiDocument]:
    def threadFunc(path, readonly):
        try:
            return WikiDocument.load(path, readonly)
        except BaseException as e:
            return e

    logger.debug('Opening notes tree from: {}'.format(path))
    if not os.path.exists(path):
        __canNotLoadWikiMessage(path)
        return None

    preWikiOpenParams = PreWikiOpenParams(path, readonly)
    Application.onPreWikiOpen(Application.selectedPage,
                              preWikiOpenParams)
    if preWikiOpenParams.abortOpen:
        logger.debug('Opening notes tree aborted')
        return None

    # The path may be changed in event handlers
    path = preWikiOpenParams.path
    logger.debug('Notes tree path after onPreWikiOpen: {}'.format(path))

    # Если передан путь до файла настроек (а не до папки с вики),
    # то оставим только папку
    if not os.path.isdir(path):
        path = os.path.split(path)[0]

    runner = LongProcessRunner(threadFunc,
                               Application.mainWindow,
                               _(u"Loading"),
                               _(u"Opening notes tree..."))
    result = runner.run(os.path.realpath(path), readonly)

    success = False
    if isinstance(result, outwiker.core.exceptions.RootFormatError):
        __rootFormatErrorHandle(path, readonly)
    elif isinstance(result, Exception):
        logger.error(result)
        __canNotLoadWikiMessage(path)
    else:
        Application.wikiroot = result
        success = True

    postWikiOpenParams = PostWikiOpenParams(path, readonly, success)
    Application.onPostWikiOpen(Application.selectedPage,
                               postWikiOpenParams)

    return Application.wikiroot
示例#6
0
def openWiki(path: str, readonly: bool=False) -> Optional[WikiDocument]:
    def threadFunc(path, readonly):
        try:
            return WikiDocument.load(path, readonly)
        except BaseException as e:
            return e

    logger.debug('Opening notes tree from: {}'.format(path))
    if not os.path.exists(path):
        __canNotLoadWikiMessage(path)
        return

    preWikiOpenParams = PreWikiOpenParams(path, readonly)
    Application.onPreWikiOpen(Application.selectedPage,
                              preWikiOpenParams)
    if preWikiOpenParams.abortOpen:
        logger.debug('Opening notes tree aborted')
        return

    # The path may be changed in event handlers
    path = preWikiOpenParams.path
    logger.debug('Notes tree path after onPreWikiOpen: {}'.format(path))

    # Если передан путь до файла настроек (а не до папки с вики),
    # то оставим только папку
    if not os.path.isdir(path):
        path = os.path.split(path)[0]

    runner = LongProcessRunner(threadFunc,
                               Application.mainWindow,
                               _(u"Loading"),
                               _(u"Opening notes tree..."))
    result = runner.run(os.path.realpath(path), readonly)

    success = False
    if isinstance(result, outwiker.core.exceptions.RootFormatError):
        __rootFormatErrorHandle(path, readonly)
    elif isinstance(result, Exception):
        logger.error(result)
        __canNotLoadWikiMessage(path)
    else:
        Application.wikiroot = result
        success = True

    postWikiOpenParams = PostWikiOpenParams(path, readonly, success)
    Application.onPostWikiOpen(Application.selectedPage,
                               postWikiOpenParams)

    return Application.wikiroot
示例#7
0
    def addStyleToBranchGui(self, page, parent):
        """
        Установить стиль для всей ветки, в том числе и для текущей страницы
        """
        with AddStyleDialog(self._application.mainWindow) as dlg:
            if dlg.ShowModal() == wx.ID_OK:
                wiki = self._application.wikiroot

                # Чтобы не вызывались никакие события при обновлении стиля
                self._application.wikiroot = None

                runner = LongProcessRunner(self.__applyStyle,
                                           self._application.mainWindow,
                                           _(u"Set Style to Branch"),
                                           _(u"Please wait..."))

                runner.run(self._application, page, dlg.style)
                # Вернем открытую вики
                self._application.wikiroot = wiki
示例#8
0
    def addStyleToBranchGui(self, page, parent):
        """
        Установить стиль для всей ветки, в том числе и для текущей страницы
        """
        with AddStyleDialog(self._application.mainWindow) as dlg:
            if dlg.ShowModal() == wx.ID_OK:
                wiki = self._application.wikiroot

                # Чтобы не вызывались никакие события при обновлении стиля
                self._application.wikiroot = None

                runner = LongProcessRunner(self.__applyStyle,
                                           self._application.mainWindow,
                                           _(u"Set Style to Branch"),
                                           _(u"Please wait..."))

                runner.run(self._application, page, dlg.style)
                # Вернем открытую вики
                self._application.wikiroot = wiki
示例#9
0
def openWiki (path, readonly=False):
    if not os.path.exists (path):
        __canNotLoadWikiMessage (path)
        return

    # Если передан путь до файла настроек (а не до папки с вики),
    # то оставим только папку
    if not os.path.isdir (path):
        path = os.path.split (path)[0]

    def threadFunc (path, readonly):
        try:
            return WikiDocument.load (path, readonly)
        except IOError as error:
            return error
        except outwiker.core.exceptions.RootFormatError as error:
            return error

    preWikiOpenParams = PreWikiOpenParams(path, readonly)
    Application.onPreWikiOpen(Application.selectedPage,
                              preWikiOpenParams)

    runner = LongProcessRunner (threadFunc,
                                Application.mainWindow,
                                _(u"Loading"),
                                _(u"Opening notes tree..."))
    result = runner.run (os.path.realpath (path), readonly)

    success = False
    if isinstance(result, IOError):
        __canNotLoadWikiMessage(path)
    elif isinstance(result, outwiker.core.exceptions.RootFormatError):
        __rootFormatErrorHandle(path, readonly)
    else:
        Application.wikiroot = result
        success = True

    postWikiOpenParams = PostWikiOpenParams(path, readonly, success)
    Application.onPostWikiOpen(Application.selectedPage,
                               postWikiOpenParams)

    return Application.wikiroot
示例#10
0
    def _onOk(self):
        self._config.longNames = self.longNames
        self._config.imagesOnly = self.imagesOnly
        self._config.overwrite = self.overwrite

        namegenerator = self.__getNameGenerator()
        exporter = BranchExporter(self.__rootpage, namegenerator,
                                  self.__application)

        runner = LongProcessRunner(self._threadExport, self,
                                   _(u"Export to HTML"), _(u"Please wait..."))

        result = runner.run(exporter, self.path, self.imagesOnly,
                            self.overwrite)

        if len(result) != 0:
            logdlg = LogDialog(self, result)
            logdlg.ShowModal()
        else:
            self.EndModal(wx.ID_OK)
示例#11
0
def openWiki(path, readonly=False):
    if not os.path.exists(path):
        __canNotLoadWikiMessage(path)
        return

    # Если передан путь до файла настроек (а не до папки с вики),
    # то оставим только папку
    if not os.path.isdir(path):
        path = os.path.split(path)[0]

    def threadFunc(path, readonly):
        try:
            return WikiDocument.load(path, readonly)
        except BaseException as e:
            return e

    preWikiOpenParams = PreWikiOpenParams(path, readonly)
    Application.onPreWikiOpen(Application.selectedPage,
                              preWikiOpenParams)

    runner = LongProcessRunner(threadFunc,
                               Application.mainWindow,
                               _(u"Loading"),
                               _(u"Opening notes tree..."))
    result = runner.run(os.path.realpath(path), readonly)

    success = False
    if isinstance(result, outwiker.core.exceptions.RootFormatError):
        __rootFormatErrorHandle(path, readonly)
    elif isinstance(result, Exception):
        logger.error(result)
        __canNotLoadWikiMessage(path)
    else:
        Application.wikiroot = result
        success = True

    postWikiOpenParams = PostWikiOpenParams(path, readonly, success)
    Application.onPostWikiOpen(Application.selectedPage,
                               postWikiOpenParams)

    return Application.wikiroot
示例#12
0
    def __onFind(self, event):
        """
        Обработчик события кнопки "Найти"
        """
        assert self.page is not None

        self.page.updateDateTime()
        self.Save()

        phrase = self.__getSearchPhrase()
        tags = self.__getSearchTags()

        searcher = Searcher(phrase, tags, self.page.strategy)

        runner = LongProcessRunner(searcher.find, self._application.mainWindow,
                                   _(u"Search"), _(u"Search pages..."))

        self._currentResultPages = runner.run(self.page.root)

        self.__saveResults(self._currentResultPages)
        self.__showResults(self._currentResultPages)
示例#13
0
    def __onFind(self, event):
        """
        Обработчик события кнопки "Найти"
        """
        assert self.page is not None

        self.page.updateDateTime()
        self.Save()

        phrase = self.__getSearchPhrase()
        tags = self.__getSearchTags()

        searcher = Searcher(phrase, tags, self.page.strategy)

        runner = LongProcessRunner(searcher.find,
                                   self._application.mainWindow,
                                   _(u"Search"),
                                   _(u"Search pages..."))

        self._currentResultPages = runner.run(self.page.root)

        self.__saveResults(self._currentResultPages)
        self.__showResults(self._currentResultPages)
示例#14
0
    def _onOk (self):
        self._config.longNames = self.longNames
        self._config.imagesOnly = self.imagesOnly
        self._config.overwrite = self.overwrite

        namegenerator = self.__getNameGenerator()
        exporter = BranchExporter (self.__rootpage, namegenerator, self.__application)

        runner = LongProcessRunner (self._threadExport,
                                    self,
                                    _(u"Export to HTML"),
                                    _(u"Please wait..."))

        result = runner.run (exporter,
                             self.path,
                             self.imagesOnly,
                             self.overwrite)

        if len (result) != 0:
            logdlg = LogDialog (self, result)
            logdlg.ShowModal()
        else:
            self.EndModal (wx.ID_OK)
示例#15
0
def openWiki (path, readonly=False):
    wikiroot = None

    Application.onStartTreeUpdate(None)

    def threadFunc (path, readonly):
        try:
            return WikiDocument.load (path, readonly)
        except IOError, error:
            return error
        except outwiker.core.exceptions.RootFormatError, error:
            return error

    runner = LongProcessRunner (threadFunc, 
            Application.mainWindow, 
            _(u"Loading"), 
            _(u"Opening notes tree..."))
    result = runner.run (os.path.realpath (path), readonly)

    if isinstance (result, IOError):
        __canNotLoadWikiMessage (path)
    elif isinstance (result, outwiker.core.exceptions.RootFormatError):
        __rootFormatErrorHandle (path, readonly)
    else:
        Application.wikiroot = result

    Application.onEndTreeUpdate(wikiroot)

    return Application.wikiroot

示例#16
0
        return

    # Если передан путь до файла настроек (а не до папки с вики),
    # то оставим только папку
    if not os.path.isdir(path):
        path = os.path.split(path)[0]

    def threadFunc(path, readonly):
        try:
            return WikiDocument.load(path, readonly)
        except IOError, error:
            return error
        except outwiker.core.exceptions.RootFormatError, error:
            return error

    runner = LongProcessRunner(threadFunc, Application.mainWindow,
                               _(u"Loading"), _(u"Opening notes tree..."))
    result = runner.run(os.path.realpath(path), readonly)

    if isinstance(result, IOError):
        __canNotLoadWikiMessage(path)
    elif isinstance(result, outwiker.core.exceptions.RootFormatError):
        __rootFormatErrorHandle(path, readonly)
    else:
        Application.wikiroot = result

    return Application.wikiroot


def __rootFormatErrorHandle(path, readonly):
    """
    Обработчик исключения outwiker.core.exceptions.RootFormatError