Ejemplo n.º 1
0
 def clearRecoverySnapshot(self, document = None):
     if document is None:
         self._clearAllSnapshots()
     else:
         snapshotFile = self._getSnapshotFileName(document)
         deleteFile(snapshotFile)
     self.logger.debug(u"Recovery snapshot cleared.") #$NON-NLS-1$
Ejemplo n.º 2
0
 def saveProperties(self):
     try:
         tempSysPropsFileName = self.sysPropsFileName + u".t" #$NON-NLS-1$
         self.sysPropsDoc.save(tempSysPropsFileName, True)
         deleteFile(self.sysPropsFileName)
         renameFile(tempSysPropsFileName, self.sysPropsFileName)
     except Exception, e:
         raise ZException(_extstr(u"sysprops.ErrorSavingPropsFile") % self.sysPropsFileName, e) #$NON-NLS-1$
Ejemplo n.º 3
0
 def deleteMediaStorage(self, mediaStore):
     self.mediaStores.remove(mediaStore)
     path = os.path.join(self.mediaStoresDirectory, mediaStore.getId() + u".store") #$NON-NLS-1$
     deleteFile(path)
     registryPath = path + u".registry" #$NON-NLS-1$
     deleteFile(registryPath)
     self.logger.debug(u"Deleted a media storage named '%s'." % mediaStore.getName()) #$NON-NLS-1$
     for listener in self.listeners:
         listener.onMediaStorageRemoved(mediaStore)
Ejemplo n.º 4
0
 def saveProperties(self):
     try:
         tempSysPropsFileName = self.sysPropsFileName + u".t"  #$NON-NLS-1$
         self.sysPropsDoc.save(tempSysPropsFileName, True)
         deleteFile(self.sysPropsFileName)
         renameFile(tempSysPropsFileName, self.sysPropsFileName)
     except Exception, e:
         raise ZException(
             _extstr(u"sysprops.ErrorSavingPropsFile") %
             self.sysPropsFileName, e)  #$NON-NLS-1$
Ejemplo n.º 5
0
    def updateFromConnectionResp(self, connectionResp):
        imagingService = getApplicationModel().getService(IZAppServiceIDs.IMAGING_SERVICE_ID)
        bgColor = self.GetBackgroundColour()
        tnParams = ZThumbnailParams(backgroundColor = (bgColor.Red(), bgColor.Green(), bgColor.Blue()), dropShadow = True)
        tnFile = os.path.join(getApplicationModel().getUserProfile().getTempDirectory(), u"_ZImagePreviewPanel_tn.png") #$NON-NLS-1$
        try:
            imagingService.generateThumbnail(connectionResp.getContentFilename(), tnParams, tnFile)

            image = wx.Image(tnFile, getImageType(tnFile))
            if image is None:
                raise ZException()

            bitmap = image.ConvertToBitmap()
            self.previewBmp.setBitmap(bitmap)
            deleteFile(tnFile)
            self.generatingMsg.Show(False)
            self.generatingMsg.stop()
            self.previewUnavailableMsg.Show(False)
            self.previewBmp.Show(True)
        except Exception, e:
            getLoggerService().exception(e)
            self.updateFromError(e)
Ejemplo n.º 6
0
 def _removeTask(self, task):
     taskXmlFilename = os.path.join(self.tasksDirectory,
                                    task.getId() + u".task")  #$NON-NLS-1$
     deleteFile(taskXmlFilename)
     taskLogFilename = taskXmlFilename + u".log"  #$NON-NLS-1$
     deleteFile(taskLogFilename)
Ejemplo n.º 7
0
 def _removeTask(self, task):
     taskXmlFilename = os.path.join(self.tasksDirectory, task.getId() + u".task") #$NON-NLS-1$
     deleteFile(taskXmlFilename)
     taskLogFilename = taskXmlFilename + u".log" #$NON-NLS-1$
     deleteFile(taskLogFilename)
Ejemplo n.º 8
0
    def save(self, defaultTranslation):
        self._journal(u"--save--") #$NON-NLS-1$

        localeStr = self.locale.toString()
        baseFileName = os.path.join(self.bundleDirectory, u"zoundry.base_%s.xml" % localeStr) #$NON-NLS-1$
        appFrameworkFileName = os.path.join(self.bundleDirectory, u"zoundry.appframework_%s.xml" % localeStr) #$NON-NLS-1$
        blogAppFileName = os.path.join(self.bundleDirectory, u"zoundry.blogapp_%s.xml" % localeStr) #$NON-NLS-1$

        if DEBUG:
            outputLogFileName = os.path.join(self.bundleDirectory, u"debug_save_%s.log" % localeStr) #$NON-NLS-1$
            outputLog = open(outputLogFileName, u"w") #$NON-NLS-1$
        self.debug(outputLog, u"Saving translation") #$NON-NLS-1$

        try:
            baseDom = ZDom()
            baseDom.loadXML(BUNDLE_TEMPLATE % localeStr)
            baseDom.documentElement.addTextNode(u"\n") #$NON-NLS-1$
            self.debug(outputLog, u"baseDom created") #$NON-NLS-1$
            appFrameworkDom = ZDom()
            appFrameworkDom.loadXML(BUNDLE_TEMPLATE % localeStr)
            appFrameworkDom.documentElement.addTextNode(u"\n") #$NON-NLS-1$
            self.debug(outputLog, u"appFrameworkDom created") #$NON-NLS-1$
            blogAppDom = ZDom()
            blogAppDom.loadXML(BUNDLE_TEMPLATE % localeStr)
            blogAppDom.documentElement.addTextNode(u"\n") #$NON-NLS-1$
            self.debug(outputLog, u"blogAppDom created") #$NON-NLS-1$

            bundleStrings = self.getBundleStrings()
            keys = bundleStrings.keys()
            keys.sort()
            for key in keys:
                self.debug(outputLog, u"Writing key: %s" % key) #$NON-NLS-1$
                try:
                    value = bundleStrings[key]
                    dom = None
                    if key in defaultTranslation.getBaseKeys():
                        dom = baseDom
                    elif key in defaultTranslation.getAppFrameworkKeys():
                        dom = appFrameworkDom
                    elif key in defaultTranslation.getBlogAppKeys():
                        dom = blogAppDom
                    elem = dom.documentElement
                    stringElem = dom.createElement(u"zb:string", BUNDLE_NS) #$NON-NLS-1$
                    stringElem.setAttribute(u"name", key) #$NON-NLS-1$
                    stringElem.setText(value)
                    elem.addTextNode(u"    ") #$NON-NLS-1$
                    elem.appendChild(stringElem)
                    elem.addTextNode(u"\n") #$NON-NLS-1$
                except Exception, e:
                    getLoggerService().exception(e)
                self.debug(outputLog, u"Done writing key: %s" % key) #$NON-NLS-1$

            self.debug(outputLog, u"Done writing all keys.") #$NON-NLS-1$
            self.debug(outputLog, u"Backing up old translations.") #$NON-NLS-1$
            backup_baseFileName = os.path.join(self.bundleDirectory, u"BACKUP_zoundry.base_%s.xml" % self.locale.toString()) #$NON-NLS-1$
            backup_appFrameworkFileName = os.path.join(self.bundleDirectory, u"BACKUP_zoundry.appframework_%s.xml" % self.locale.toString()) #$NON-NLS-1$
            backup_blogAppFileName = os.path.join(self.bundleDirectory, u"BACKUP_zoundry.blogapp_%s.xml" % self.locale.toString()) #$NON-NLS-1$
            if os.path.exists(baseFileName):
                shutil.copy2(baseFileName, backup_baseFileName)
            if os.path.exists(appFrameworkFileName):
                shutil.copy2(appFrameworkFileName, backup_appFrameworkFileName)
            if os.path.exists(blogAppFileName):
                shutil.copy2(blogAppFileName, backup_blogAppFileName)

            self.debug(outputLog, u"Saving DOMs") #$NON-NLS-1$

            baseDom.save(baseFileName)
            self.debug(outputLog, u"Successfully saved baseDom") #$NON-NLS-1$
            appFrameworkDom.save(appFrameworkFileName)
            self.debug(outputLog, u"Successfully saved appFrameworkDom") #$NON-NLS-1$
            blogAppDom.save(blogAppFileName)
            self.debug(outputLog, u"Successfully saved blogAppDom") #$NON-NLS-1$

            deleteFile(backup_baseFileName)
            deleteFile(backup_appFrameworkFileName)
            deleteFile(backup_blogAppFileName)

            self.debug(outputLog, u"Deleted backup files.") #$NON-NLS-1$