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