Exemple #1
0
    def _updateHtmlWindow(self):
        """
        Подготовить и показать HTML текущей страницы
        """
        assert self._currentpage is not None

        setStatusText(_(u"Page loading. Please wait…"), self._statusbar_item)

        try:
            path = self._currentpage.getHtmlPath()
            if not os.path.exists(path):
                self._updatePage()

            html = readTextFile(path)

            if(self._oldPage != self._currentpage or
                    self._oldHtmlResult != html):
                self.htmlWindow.LoadPage(path)
                self._oldHtmlResult = html
                self._oldPage = self._currentpage
        except EnvironmentError as e:
            logger.error(str(e))
            MessageBox(_(u'Page loading error: {}').format(
                self._currentpage.title),
                _(u'Error'), wx.ICON_ERROR | wx.OK)

        setStatusText(u"", self._statusbar_item)
    def _showUpdates (self, verList):
        """
        Сверяем полученные номера версий с теми, что установлены сейчас и заполняем диалог изменениями (updateDialog)
        Возвращает True, если есть какие-нибудь обновления
        """
        setStatusText (u"")

        currentVersion = getCurrentVersion()
        stableVersion = verList.stableVersion
        unstableVersion = verList.unstableVersion

        updatedPlugins = self.getUpdatedPlugins (verList)

        updateDialog = UpdateDialog (self._application.mainWindow)
        updateDialog.setCurrentOutWikerVersion (currentVersion)

        if stableVersion != None:
            updateDialog.setLatestStableOutwikerVersion (stableVersion, currentVersion < stableVersion)
        else:
            updateDialog.setLatestStableOutwikerVersion (currentVersion, False)

        if unstableVersion != None:
            updateDialog.setLatestUnstableOutwikerVersion (unstableVersion, currentVersion < unstableVersion)
        else:
            updateDialog.setLatestUnstableOutwikerVersion (currentVersion, False)

        for plugin in updatedPlugins:
            updateDialog.addPluginInfo (plugin,
                    verList.getPluginVersion (plugin.name),
                    verList.getPluginUrl (plugin.name))

        updateDialog.ShowModal()
        updateDialog.Destroy()
Exemple #3
0
    def _showHtml (self):
        """
        Подготовить и показать HTML текущей страницы
        """
        assert self._currentpage != None
        
        status_item = 0

        setStatusText (_(u"Page rendered. Please wait…"), status_item)
        Application.onHtmlRenderingBegin (self._currentpage, self.htmlWindow)

        try:
            self.currentHtmlFile = self.generateHtml (self._currentpage)
            self.htmlWindow.LoadPage (self.currentHtmlFile)
        except IOError as e:
            # TODO: Проверить под Windows
            MessageBox (_(u"Can't save file %s") % (unicode (e.filename)), 
                    _(u"Error"), 
                    wx.ICON_ERROR | wx.OK)
        except OSError as e:
            MessageBox (_(u"Can't save HTML-file\n\n%s") % (unicode (e)), 
                    _(u"Error"), 
                    wx.ICON_ERROR | wx.OK)

        setStatusText (u"", status_item)
        Application.onHtmlRenderingEnd (self._currentpage, self.htmlWindow)
Exemple #4
0
    def _onSwitchCodeHtml (self):
        assert self._currentpage != None

        self.Save()
        status_item = 0
        setStatusText (_(u"Page rendered. Please wait…"), status_item)
        Application.onHtmlRenderingBegin (self._currentpage, self.htmlWindow)

        try:
            self.currentHtmlFile = self.generateHtml (self._currentpage)
            self._showHtmlCode(self.currentHtmlFile)
        except IOError as e:
            # TODO: Проверить под Windows
            MessageBox (_(u"Can't save file %s") % (unicode (e.filename)), 
                    _(u"Error"), 
                    wx.ICON_ERROR | wx.OK)
        except OSError as e:
            MessageBox (_(u"Can't save HTML-file\n\n%s") % (unicode (e)), 
                    _(u"Error"), 
                    wx.ICON_ERROR | wx.OK)

        setStatusText (u"", status_item)
        Application.onHtmlRenderingEnd (self._currentpage, self.htmlWindow)

        self._enableAllTools ()
        self.htmlCodeWindow.SetFocus()
        self.htmlCodeWindow.Update()
Exemple #5
0
    def _updateHtmlWindow(self):
        """
        Подготовить и показать HTML текущей страницы
        """
        assert self._currentpage is not None

        setStatusText(_(u"Page loading. Please wait…"), self._statusbar_item)

        try:
            path = self._currentpage.getHtmlPath()
            if not os.path.exists(path):
                self._updatePage()

            html = readTextFile(path)

            if (self._oldPage != self._currentpage
                    or self._oldHtmlResult != html):
                self.htmlWindow.LoadPage(path)
                self._oldHtmlResult = html
                self._oldPage = self._currentpage
        except EnvironmentError as e:
            logger.error(str(e))
            MessageBox(
                _(u'Page loading error: {}').format(self._currentpage.title),
                _(u'Error'), wx.ICON_ERROR | wx.OK)

        setStatusText(u"", self._statusbar_item)
    def _onSilenceVersionUpdate (self, event):
        setStatusText (u"")

        if self.hasUpdates (event.verList):
            self._showUpdates (event.verList)
            self._touchLastUpdateDate()

        self._silenceThread = None
Exemple #7
0
    def _onSilenceVersionUpdate(self, event):
        setStatusText(u"")

        if self._isLoadingSuccess(event.verList):
            self._touchLastUpdateDate()

            if self.hasUpdates(event.verList):
                self._showUpdates(event.verList)

        self._silenceThread = None
Exemple #8
0
    def checkForUpdatesSilence(self):
        """
        Execute the silence update checking.
        """
        setStatusText(_(u"Check for new versions..."))

        if (self._silenceThread is None or not self._silenceThread.isAlive()):
            self._silenceThread = threading.Thread(
                None, self._threadFunc, args=(self._updateUrls.copy(), True))
            self._silenceThread.start()
Exemple #9
0
    def _showUpdates(self, updatedAppInfo):
        '''
        Show dialog with update information.
        '''
        setStatusText(u"")

        HTMLContent = self.createHTMLContent(updatedAppInfo)

        with UpdateDialog(self._application.mainWindow) as updateDialog:
            basepath = self._dataPath
            updateDialog.setContent(HTMLContent, basepath)
            updateDialog.ShowModal()
Exemple #10
0
    def updatePageDateTime (self):
        statusbar_item = 1
        config = GeneralGuiConfig (Application.config)

        dateFormat = config.dateTimeFormat.value
        text = u""

        if (Application.selectedPage != None and 
            Application.selectedPage.datetime != None):
                text = datetime.datetime.strftime (Application.selectedPage.datetime, dateFormat)

        setStatusText (text, statusbar_item)
Exemple #11
0
    def updatePageDateTime(self):
        statusbar_item = 1

        dateFormat = self._generalConfig.dateTimeFormat.value
        text = u""

        if (self._application.selectedPage is not None
                and self._application.selectedPage.datetime is not None):
            text = datetime.datetime.strftime(
                self._application.selectedPage.datetime, dateFormat)

        setStatusText(text, statusbar_item)
Exemple #12
0
    def checkForUpdatesSilence (self):
        """
        Молчаливое обновление списка версий
        """
        setStatusText (_(u"Check for new versions..."))
        verList = VersionList (self._application.plugins)

        if (self._silenceThread == None or
                not self._silenceThread.isAlive()):

            self._silenceThread = threading.Thread (None, self._silenceThreadFunc, args=(verList,))
            self._silenceThread.start()
Exemple #13
0
    def updatePageDateTime (self):
        statusbar_item = 1
        config = GeneralGuiConfig (Application.config)

        dateFormat = config.dateTimeFormat.value
        text = u""

        if (Application.selectedPage is not None and
                Application.selectedPage.datetime is not None):
            text = datetime.datetime.strftime (Application.selectedPage.datetime, dateFormat)

        setStatusText (text, statusbar_item)
Exemple #14
0
    def _showUpdates(self, appInfoDict, updatedAppInfo, installerInfoDict):
        '''
        Show dialog with update information.
        '''
        setStatusText(u"")

        HTMLContent = self.createHTMLContent(
            appInfoDict, updatedAppInfo, installerInfoDict)

        with UpdateDialog(self._application.mainWindow) as updateDialog:
            self._dialog = updateDialog
            updateDialog.setContent(HTMLContent, self._dataPath)
            updateDialog.ShowModal()
Exemple #15
0
    def _updatePage(self):
        assert self._currentpage is not None

        setStatusText(_(u"Page rendered. Please wait…"), self._statusbar_item)
        self._application.onHtmlRenderingBegin(self._currentpage,
                                               self.htmlWindow)

        self._application.onPageUpdateNeeded(self._currentpage,
                                             PageUpdateNeededParams(True))

        setStatusText(u"", self._statusbar_item)
        self._application.onHtmlRenderingEnd(self._currentpage,
                                             self.htmlWindow)
Exemple #16
0
    def _onVersionUpdate(self, event):
        '''
        Event handler for EVT_UPDATE_VERSIONS.
        '''
        setStatusText(u"")

        updatedAppInfo = self._getUpdatedAppInfo(event.appInfoDict)
        self._touchLastUpdateDate()

        if updatedAppInfo:
            self._showUpdates(updatedAppInfo)
        elif not event.silenceMode:
            MessageBox(_(u"Updates not found"), u"UpdateNotifier")
Exemple #17
0
    def checkForUpdatesSilence(self):
        """
        Execute the silence update checking.
        """
        setStatusText(_(u"Check for new versions..."))

        if (self._silenceThread is None or not self._silenceThread.isAlive()):
            self._silenceThread = threading.Thread(
                None,
                self._threadFunc,
                args=(self._updateUrls.copy(), True)
            )
            self._silenceThread.start()
Exemple #18
0
    def _updatePage(self):
        assert self._currentpage is not None

        setStatusText(_(u"Page rendered. Please wait…"), self._statusbar_item)
        self._application.onHtmlRenderingBegin(self._currentpage,
                                               self.htmlWindow)

        self._application.onPageUpdateNeeded(self._currentpage,
                                             PageUpdateNeededParams(True))

        setStatusText(u"", self._statusbar_item)
        self._application.onHtmlRenderingEnd(self._currentpage,
                                             self.htmlWindow)
Exemple #19
0
    def updatePageDateTime(self):
        statusbar_item = 1

        dateFormat = self._generalConfig.dateTimeFormat.value
        text = u""

        if(self._application.selectedPage is not None and
                self._application.selectedPage.datetime is not None):
            text = datetime.datetime.strftime(
                self._application.selectedPage.datetime,
                dateFormat)

        setStatusText(text, statusbar_item)
Exemple #20
0
    def checkForUpdatesSilence(self):
        """
        Молчаливое обновление списка версий
        """
        setStatusText(_(u"Check for new versions..."))
        verList = VersionList(self._application.plugins)

        if (self._silenceThread is None or not self._silenceThread.isAlive()):

            self._silenceThread = threading.Thread(None,
                                                   self._silenceThreadFunc,
                                                   args=(verList, ))
            self._silenceThread.start()
    def _showUpdates(self, appInfoDict, updatedAppInfo, installerInfoDict):
        '''
        Show dialog with update information.
        '''
        setStatusText(u"")

        HTMLContent = self.createHTMLContent(
            appInfoDict, updatedAppInfo, installerInfoDict)

        with UpdateDialog(self._application.mainWindow) as updateDialog:
            self._dialog = updateDialog
            updateDialog.setContent(HTMLContent, self._dataPath)
            updateDialog.ShowModal()
Exemple #22
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)
Exemple #23
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)
Exemple #24
0
    def _onVersionUpdate(self, event):
        '''
        Event handler for EVT_UPDATE_VERSIONS.
        '''
        setStatusText(u"")
        self._touchLastUpdateDate()

        updatedAppInfo = self._getUpdatedAppInfo(event.plugInfoDict)

        if event.silenceMode:
            if updatedAppInfo:
                self._showUpdates(event.appInfoDict, event.plugInfoDict,
                                  event.installerInfoDict)
        else:
            self._showUpdates(event.appInfoDict, event.plugInfoDict,
                              event.installerInfoDict)
Exemple #25
0
    def _updateResult(self):
        """
        Подготовить и показать HTML текущей страницы
        """
        assert self._currentpage is not None

        status_item = 0

        setStatusText(_(u"Page rendered. Please wait…"), status_item)
        self._application.onHtmlRenderingBegin(self._currentpage,
                                               self.htmlWindow)

        try:
            html = self.generateHtml(self._currentpage)

            if (self._oldPage != self._currentpage
                    or self._oldHtmlResult != html):
                path = self.getHtmlPath()

                if not self._currentpage.readonly:
                    writeTextFile(path, html)

                self.htmlWindow.LoadPage(path)
                self._oldHtmlResult = html
                self._oldPage = self._currentpage
        except IOError as e:
            # TODO: Проверить под Windows
            MessageBox(
                _(u"Can't save file\n\n{}").format(
                    unicode(e.filename,
                            getOS().filesEncoding)), _(u"Error"),
                wx.ICON_ERROR | wx.OK)
        except OSError as e:
            MessageBox(
                _(u"Can't save file\n\n{}").format(
                    unicode(e.strerror,
                            getOS().filesEncoding)), _(u"Error"),
                wx.ICON_ERROR | wx.OK)

        setStatusText(u"", status_item)
        self._application.onHtmlRenderingEnd(self._currentpage,
                                             self.htmlWindow)
Exemple #26
0
    def checkForUpdates (self):
        """
        Проверить обновления и показать диалог с результатами
        """
        verList = VersionList (self._application.plugins)
        setStatusText (_(u"Check for new versions..."))

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

        progressRunner.run()

        if self.hasUpdates (verList):
            self._showUpdates (verList)
            self._touchLastUpdateDate()
        else:
            MessageBox (_(u"Updates not found"),
                    u"UpdateNotifier")
Exemple #27
0
    def _onVersionUpdate(self, event):
        '''
        Event handler for EVT_UPDATE_VERSIONS.
        '''
        setStatusText(u"")
        self._touchLastUpdateDate()

        updatedAppInfo = self._getUpdatedAppInfo(event.plugInfoDict)

        if event.silenceMode:
            if updatedAppInfo:
                self._showUpdates(
                    event.appInfoDict,
                    event.plugInfoDict,
                    event.installerInfoDict)
        else:
            self._showUpdates(
                event.appInfoDict,
                event.plugInfoDict,
                event.installerInfoDict)
Exemple #28
0
    def checkForUpdates(self):
        """
        Проверить обновления и показать диалог с результатами
        """
        verList = VersionList(self._application.plugins)
        setStatusText(_(u"Check for new versions..."))

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

        progressRunner.run()

        if self._isLoadingSuccess(verList):
            self._touchLastUpdateDate()

            if self.hasUpdates(verList):
                self._showUpdates(verList)
            else:
                MessageBox(_(u"Updates not found"), u"UpdateNotifier")
Exemple #29
0
    def _showUpdates(self, verList):
        """
        Сверяем полученные номера версий с теми, что установлены сейчас и заполняем диалог изменениями (updateDialog)
        Возвращает True, если есть какие-нибудь обновления
        """
        setStatusText(u"")

        currentVersion = getCurrentVersion()
        stableVersion = verList.stableVersion
        unstableVersion = verList.unstableVersion

        updatedPlugins = self.getUpdatedPlugins(verList)

        updateDialog = UpdateDialog(self._application.mainWindow)
        updateDialog.setCurrentOutWikerVersion(currentVersion)

        if stableVersion is not None:
            updateDialog.setLatestStableOutwikerVersion(
                stableVersion, currentVersion < stableVersion)
        else:
            updateDialog.setLatestStableOutwikerVersion(currentVersion, False)

        if unstableVersion is not None:
            updateDialog.setLatestUnstableOutwikerVersion(
                unstableVersion, currentVersion < unstableVersion)
        else:
            updateDialog.setLatestUnstableOutwikerVersion(
                currentVersion, False)

        for plugin in updatedPlugins:
            updateDialog.addPluginInfo(plugin,
                                       verList.getPluginVersion(plugin.name),
                                       verList.getPluginUrl(plugin.name))

        updateDialog.ShowModal()
        updateDialog.Destroy()
Exemple #30
0
    def _updateResult (self):
        """
        Подготовить и показать HTML текущей страницы
        """
        assert self._currentpage is not None

        status_item = 0

        setStatusText (_(u"Page rendered. Please wait…"), status_item)
        self._application.onHtmlRenderingBegin (self._currentpage, self.htmlWindow)

        try:
            html = self.generateHtml (self._currentpage)

            if (self._oldPage != self._currentpage or
                    self._oldHtmlResult != html):
                path = self.getHtmlPath()

                if not self._currentpage.readonly:
                    writeTextFile (path, html)

                self.htmlWindow.LoadPage (path)
                self._oldHtmlResult = html
                self._oldPage = self._currentpage
        except IOError as e:
            # TODO: Проверить под Windows
            MessageBox (_(u"Can't save file\n\n{}").format (unicode (e.filename, getOS().filesEncoding)),
                        _(u"Error"),
                        wx.ICON_ERROR | wx.OK)
        except OSError as e:
            MessageBox (_(u"Can't save file\n\n{}").format (unicode (e.strerror, getOS().filesEncoding)),
                        _(u"Error"),
                        wx.ICON_ERROR | wx.OK)

        setStatusText (u"", status_item)
        self._application.onHtmlRenderingEnd (self._currentpage, self.htmlWindow)