Пример #1
0
 def _warning(self, message):
     self._logActivity(message)
     if getLoggerService():
         getLoggerService().warning(message)
     else:
         print message.encode(u'iso-8859-1',
                              u'replace')  #$NON-NLS-1$ #$NON-NLS-2$
Пример #2
0
 def stop(self):
     for key in self.services:
         service = self.services[key]
         try:
             service.stop()
         except Exception, e:
             getLoggerService().exception(e)
Пример #3
0
 def logError(self, izBlogPublishHandler, message): #@UnusedVariable
     s = u"[ERROR][%s] %s" % (izBlogPublishHandler.getName(), message) #$NON-NLS-1$
     self._debug(izBlogPublishHandler, s)
     if getLoggerService():
         getLoggerService().error(message)
     else:
         print message.encode(u'iso-8859-1', u'replace') #$NON-NLS-1$ #$NON-NLS-2$
Пример #4
0
 def _fireIndexChangeEvent(self, listeners, eventClass, IDOs):
     for ido in IDOs:
         for listener in listeners:
             try:
                 listener.onIndexChange(eventClass(ido))
             except Exception, e:
                 getLoggerService().exception(e)
Пример #5
0
 def run(self):
     docIDs = self.dataStore.getDocumentIDs()
     for docID in docIDs:
         getLoggerService().debug(u"Loading document %s." % docID) #$NON-NLS-1$
         document = self.dataStore.getDocument(docID)
         getLoggerService().debug(u"Indexing document %s." % docID) #$NON-NLS-1$
         self.docIndex.onDocumentAdded(document)
Пример #6
0
def saveTemplate(template):
    try:
        serializer = getTemplateSerializerFactory().getSerializer()
        serializer.serialize(template)
    except Exception, e:
        getLoggerService().exception(e)
        raise ZBlogAppException(u"Failed to save template: %s" % template.getDirectoryPath(), e) #$NON-NLS-1$
Пример #7
0
 def updateFromError(self, error):
     # Log the error
     getLoggerService().exception(error)
     self.generatingMsg.Show(False)
     self.generatingMsg.stop()
     self.previewUnavailableMsg.Show(True)
     self.previewBmp.Show(False)
Пример #8
0
 def _fireIndexChangeEvent(self, listeners, eventClass, IDOs):
     for ido in IDOs:
         for listener in listeners:
             try:
                 listener.onIndexChange(eventClass(ido))
             except Exception, e:
                 getLoggerService().exception(e)
Пример #9
0
 def _takeRecoverySnapshot(self):
     try:
         self._updateModel()
         document = self.getDocument()
         crashRecoveryService = getApplicationModel().getService(IZBlogAppServiceIDs.CRASH_RECOVERY_SERVICE_ID)
         crashRecoveryService.takeRecoverySnapshot(document)
     except Exception, e:
         getLoggerService().exception(e)
Пример #10
0
def saveTemplate(template):
    try:
        serializer = getTemplateSerializerFactory().getSerializer()
        serializer.serialize(template)
    except Exception, e:
        getLoggerService().exception(e)
        raise ZBlogAppException(u"Failed to save template: %s" %
                                template.getDirectoryPath(), e)  #$NON-NLS-1$
Пример #11
0
 def updateFromError(self, error):
     # Log the error
     getLoggerService().exception(error)
     self.fileSize.SetLabel(
         _extstr(u"infodetailswidgets.Unavailable"))  #$NON-NLS-1$
     self.linkType.SetLabel(
         _extstr(u"infodetailswidgets.Unavailable"))  #$NON-NLS-1$
     self.Layout()
Пример #12
0
 def updateFromError(self, error):
     # Log the error
     getLoggerService().exception(error)
     self.fileSize.SetLabel(_extstr(u"infodetailswidgets.Unavailable")) #$NON-NLS-1$
     self.imageWidth.SetLabel(_extstr(u"infodetailswidgets.Unavailable")) #$NON-NLS-1$
     self.imageHeight.SetLabel(_extstr(u"infodetailswidgets.Unavailable")) #$NON-NLS-1$
     self.imageType.SetLabel(_extstr(u"infodetailswidgets.Unavailable")) #$NON-NLS-1$
     self.Layout()
Пример #13
0
 def _doPaint(self, paintDC):
     try:
         self._drawBorder(paintDC)
         self._drawBitmap(paintDC)
         if self.showTextFlag:
             self._drawText(paintDC)
     except Exception, e:
         getLoggerService().exception(e)
Пример #14
0
 def updateFromConnectionRespInfo(self, connectionRespInfo):
     # FIXME (EPW) pretty-format the file size (KB, MB, etc)
     if connectionRespInfo is not None and connectionRespInfo.getContentLength() is not None:
         try:
             self.fileSize.SetLabel(u"%d bytes" % connectionRespInfo.getContentLength()) #$NON-NLS-1$
             self.imageType.SetLabel(connectionRespInfo.getContentType())
         except Exception, e:
             getLoggerService().exception(e)
             getLoggerService().warning(u"Content length was of type '%s'." % unicode(type(connectionRespInfo.getContentLength()))) #$NON-NLS-1$
Пример #15
0
 def logError(self, izBlogPublishHandler, message):  #@UnusedVariable
     s = u"[ERROR][%s] %s" % (izBlogPublishHandler.getName(), message
                              )  #$NON-NLS-1$
     self._debug(izBlogPublishHandler, s)
     if getLoggerService():
         getLoggerService().error(message)
     else:
         print message.encode(u'iso-8859-1',
                              u'replace')  #$NON-NLS-1$ #$NON-NLS-2$
Пример #16
0
 def _logSelectQueryTimings(self, sql, startTime, execTime, fetchTime,
                            endTime):
     total = unicode(round((endTime - startTime) * 1000))
     execute = unicode(round((execTime - startTime) * 1000))
     fetch = unicode(round((fetchTime - execTime) * 1000))
     handle = unicode(round((endTime - fetchTime) * 1000))
     getLoggerService().debug(
         u"SQLSELECT (total=%s :: exec=%s, fetch=%s, handle=%s): %s" %
         (total, execute, fetch, handle, sql))  #$NON-NLS-1$
Пример #17
0
 def run(self):
     docIDs = self.dataStore.getDocumentIDs()
     for docID in docIDs:
         getLoggerService().debug(u"Loading document %s." %
                                  docID)  #$NON-NLS-1$
         document = self.dataStore.getDocument(docID)
         getLoggerService().debug(u"Indexing document %s." %
                                  docID)  #$NON-NLS-1$
         self.docIndex.onDocumentAdded(document)
Пример #18
0
 def handleException(self, type, value, tb):
     # Log the exception in the logger
     zexception = None
     if isinstance(value, ZException):
         zexception = value
     elif isinstance(value, Exception):
         zexception = ZException(rootCause = value)
     else:
         zexception = ZException(unicode(value), None, (type, value, tb))
     getLoggerService().exception(zexception)
     # Show the error to the user.
     ZShowExceptionWithFeedback(getApplicationModel().getTopWindow(), zexception)
Пример #19
0
 def GetDropTarget(self, oldDropTarget): #@UnusedVariable
     if self.dropTarget != None:
         return self.dropTarget
     try:
         oldDropTargetDispatch = oldDropTarget.QueryInterface(pythoncom.IID_IDropTarget) #@UndefinedVariable
         dropTarget = ZMshtmlDropTarget(self.mshtmlCtrl, oldDropTargetDispatch)
         self.dropTarget = win32com.server.util.wrap(dropTarget, pythoncom.IID_IDropTarget) #@UndefinedVariable
         return self.dropTarget
     except Exception, e:
         ze = ZException(rootCause = e)
         getLoggerService().exception(ze)
         return oldDropTarget
Пример #20
0
 def handleException(self, type, value, tb):
     # Log the exception in the logger
     zexception = None
     if isinstance(value, ZException):
         zexception = value
     elif isinstance(value, Exception):
         zexception = ZException(rootCause=value)
     else:
         zexception = ZException(unicode(value), None, (type, value, tb))
     getLoggerService().exception(zexception)
     # Show the error to the user.
     ZShowExceptionWithFeedback(getApplicationModel().getTopWindow(),
                                zexception)
Пример #21
0
def getBitmapFromClipboard():
    u"""Returns clipboard bitmap if available or None otherwise.""" #$NON-NLS-1$
    bmp = None
    try:
        wx.TheClipboard.Open()
        ok = wx.TheClipboard.IsSupported(wx.DataFormat(wx.DF_BITMAP)) or wx.TheClipboard.IsSupported(wx.DataFormat(wx.DF_DIB))
        if ok:
            bmpdata= wx.BitmapDataObject()
            if wx.TheClipboard.GetData(bmpdata):
                bmp = bmpdata.GetBitmap()
        wx.TheClipboard.Close()
    except Exception, e:
        getLoggerService().exception(e)
Пример #22
0
 def isEnabled(self, context): #@UnusedVariable
     docIDO = context.getDocumentIDO()
     docId = docIDO.getId()
     document = self._getDataStore().getDocument(docId)
     blogInfo = self._getBlogInfo(context, document)
     if blogInfo is not None:
         pubInfo = blogInfo.getPublishInfo()
         if pubInfo is not None:
             url = pubInfo.getUrl()
             if url:
                 return True
             else:
                 getLoggerService().error(u"Pub URL for doc id '%s' was 'None'." % docId) #$NON-NLS-1$
     return False
Пример #23
0
 def GetDropTarget(self, oldDropTarget):  #@UnusedVariable
     if self.dropTarget != None:
         return self.dropTarget
     try:
         oldDropTargetDispatch = oldDropTarget.QueryInterface(
             pythoncom.IID_IDropTarget)  #@UndefinedVariable
         dropTarget = ZMshtmlDropTarget(self.mshtmlCtrl,
                                        oldDropTargetDispatch)
         self.dropTarget = win32com.server.util.wrap(
             dropTarget, pythoncom.IID_IDropTarget)  #@UndefinedVariable
         return self.dropTarget
     except Exception, e:
         ze = ZException(rootCause=e)
         getLoggerService().exception(ze)
         return oldDropTarget
Пример #24
0
def getBitmapFromClipboard():
    u"""Returns clipboard bitmap if available or None otherwise."""  #$NON-NLS-1$
    bmp = None
    try:
        wx.TheClipboard.Open()
        ok = wx.TheClipboard.IsSupported(wx.DataFormat(
            wx.DF_BITMAP)) or wx.TheClipboard.IsSupported(
                wx.DataFormat(wx.DF_DIB))
        if ok:
            bmpdata = wx.BitmapDataObject()
            if wx.TheClipboard.GetData(bmpdata):
                bmp = bmpdata.GetBitmap()
        wx.TheClipboard.Close()
    except Exception, e:
        getLoggerService().exception(e)
Пример #25
0
 def isEnabled(self, context):  #@UnusedVariable
     docIDO = context.getDocumentIDO()
     docId = docIDO.getId()
     document = self._getDataStore().getDocument(docId)
     blogInfo = self._getBlogInfo(context, document)
     if blogInfo is not None:
         pubInfo = blogInfo.getPublishInfo()
         if pubInfo is not None:
             url = pubInfo.getUrl()
             if url:
                 return True
             else:
                 getLoggerService().error(
                     u"Pub URL for doc id '%s' was 'None'." %
                     docId)  #$NON-NLS-1$
     return False
Пример #26
0
def getPngFileFromClipboard(copyToResourceStore=False):
    u"""Returns the (temp) file path to png file representing the clipboard bitmap or None otherwise.
    If copyToResourceStore = true, then the tmp image file is copied to the resource store.
    """ #$NON-NLS-1$
    filepath = None
    bmp = getBitmapFromClipboard()
    if bmp:
        try:
            osutil = getOSUtil()
            tempDir = osutil.getSystemTempDirectory()
            name = generateFilename(u"zrclip", u".png") #$NON-NLS-1$ #$NON-NLS-2$
            filepath = os.path.abspath( os.path.join(tempDir, name) )
            bmp.SaveFile(filepath, wx.BITMAP_TYPE_PNG)
        except Exception, e:
            filepath = None
            getLoggerService().exception(e)
Пример #27
0
    def _validateBlog(self, blog, validationReporter):
        zaccount = blog.getAccount()
        if not zaccount:
            # defect 534 work around - should not get here
            logger = getLoggerService()
            logger.error(u"Account information not available for Blog ID %s" % blog.getId() ) #$NON-NLS-1$
            validationReporter.addError(u"Blog Account", u"Account information not available for blog %s" % blog.getName() ) #$NON-NLS-1$ #$NON-NLS-2$
            return

        username = zaccount.getAttribute(u"username")#$NON-NLS-1$
        if not getNoneString(username):
            validationReporter.addError(u"Blog Account", u"Username is missing for blog %s" % blog.getName() ) #$NON-NLS-1$ #$NON-NLS-2$
        cyppass = zaccount.getAttribute(u"password")#$NON-NLS-1$
        if not getNoneString(cyppass):
            validationReporter.addError(u"Blog Account", u"Password is missing for blog %s" % blog.getName() ) #$NON-NLS-1$ #$NON-NLS-2$
        else:
            password = None
            try:
                password = crypt.decryptCipherText(cyppass, PASSWORD_ENCRYPTION_KEY)
            except:
                pass
            if not getNoneString(password):
                validationReporter.addError(u"Blog Account", u"Invalid password set for blog %s. Please set the blog account password." % blog.getName() ) #$NON-NLS-1$ #$NON-NLS-2$

        apiInfo = zaccount.getAPIInfo()
        url = apiInfo.getUrl()
        if not getNoneString(url):
            validationReporter.addError(u"Blog Account", u"Blog API URL is required for blog %s" % blog.getName() ) #$NON-NLS-1$ #$NON-NLS-2$

        siteId = apiInfo.getType()
        if not getNoneString(siteId):
            validationReporter.addError(u"Blog Account", u"Blog API type is required for blog %s" % blog.getName() ) #$NON-NLS-1$ #$NON-NLS-2$
Пример #28
0
 def __init__(self, nonPortablePathElementInfos):
     self.nonPortablePathElementInfos = nonPortablePathElementInfos
     self.logger = getLoggerService()
     self.copiedContent  = {}
     self.currFileCopiedBytes = 0
     self.currFileTotalBytes = 0
     self.currProgressText = u"" #$NON-NLS-1$
     ZAbstractRunnableProgress.__init__(self)
Пример #29
0
def getPngFileFromClipboard(copyToResourceStore=False):
    u"""Returns the (temp) file path to png file representing the clipboard bitmap or None otherwise.
    If copyToResourceStore = true, then the tmp image file is copied to the resource store.
    """ #$NON-NLS-1$
    filepath = None
    bmp = getBitmapFromClipboard()
    if bmp:
        try:
            osutil = getOSUtil()
            tempDir = osutil.getSystemTempDirectory()
            name = generateFilename(u"zrclip",
                                    u".png")  #$NON-NLS-1$ #$NON-NLS-2$
            filepath = os.path.abspath(os.path.join(tempDir, name))
            bmp.SaveFile(filepath, wx.BITMAP_TYPE_PNG)
        except Exception, e:
            filepath = None
            getLoggerService().exception(e)
Пример #30
0
    def __init__(self, actionContext, url, linkContext):
        self.actionContext = actionContext
        self.url = url
        self.linkContext = linkContext
        self.zoundryProductUrl = None
        self.logger = getLoggerService()

        ZAbstractRunnableProgress.__init__(self)
Пример #31
0
 def __init__(self, name):
     self.name = name
     self.error = None
     self.canceled = False
     self.totalWorkUnits = 0
     self.abortOnError = False
     self.context = None
     self.logger = getLoggerService()
Пример #32
0
 def __init__(self, name):
     self.name = name
     self.error = None
     self.canceled = False
     self.totalWorkUnits = 0
     self.abortOnError = False
     self.context = None
     self.logger = getLoggerService()
Пример #33
0
    def __init__(self, actionContext, url, linkContext):
        self.actionContext = actionContext
        self.url = url
        self.linkContext = linkContext
        self.zoundryProductUrl = None
        self.logger = getLoggerService()

        ZAbstractRunnableProgress.__init__(self)
Пример #34
0
    def onContextMenu(self, event):
        linkCtx = self.getLinkContext()
        imageCtx = self.getImageContext()
        tableCtx = self.getTableContext()
        removeExtMarker = False
        if self.hasCapability(IZBlogPostEditControl.ZCAPABILITY_EXTENDED_ENTRY_MARKER) \
            and self._getContentEditControl().canRemoveExtendedEntryMarker():
            removeExtMarker = True

        menuModel = ZBlogContentEditorContextMenuModel()
        menuModel.initialize(linkCtx, imageCtx, tableCtx, removeExtMarker)

        menuContext = self.zblogPostEditor.getMenuActionContext()
        contentProvider = ZModelBasedMenuContentProvider(menuModel, menuContext)
        eventHandler = ZModelBasedMenuEventHandler(menuModel, menuContext)
        menu = ZMenu(event.getParentWindow(), menuModel.getRootNode(), contentProvider, eventHandler)
        try:
            event.getParentWindow().PopupMenu(menu, event.getXYPoint())
        except Exception, e:
            getLoggerService().exception(e)
Пример #35
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)
Пример #36
0
    def onContextMenu(self, event):
        linkCtx = self.getLinkContext()
        imageCtx = self.getImageContext()
        tableCtx = self.getTableContext()
        removeExtMarker = False
        if self.hasCapability(IZBlogPostEditControl.ZCAPABILITY_EXTENDED_ENTRY_MARKER) \
            and self._getContentEditControl().canRemoveExtendedEntryMarker():
            removeExtMarker = True

        menuModel = ZBlogContentEditorContextMenuModel()
        menuModel.initialize(linkCtx, imageCtx, tableCtx, removeExtMarker)

        menuContext = self.zblogPostEditor.getMenuActionContext()
        contentProvider = ZModelBasedMenuContentProvider(
            menuModel, menuContext)
        eventHandler = ZModelBasedMenuEventHandler(menuModel, menuContext)
        menu = ZMenu(event.getParentWindow(), menuModel.getRootNode(),
                     contentProvider, eventHandler)
        try:
            event.getParentWindow().PopupMenu(menu, event.getXYPoint())
        except Exception, e:
            getLoggerService().exception(e)
Пример #37
0
 def _getPicasaServer(self):
     if not self.picasaServer:
         username = None
         password = None
         if u"username" in self.properties: #$NON-NLS-1$
             username = getNoneString(self.properties[u"username"]) #$NON-NLS-1$
         if not username:
             raise ZException(u"Picasa web album account username is required.") #$NON-NLS-1$
         if u"password" in self.properties: #$NON-NLS-1$
             password = getNoneString(self.properties[u"password"]) #$NON-NLS-1$
         if not password:
             raise ZException(u"Picasa web album account password is required.") #$NON-NLS-1$
         self.picasaServer = ZPicasaServer(username, password)
         self.picasaServer.setLogger(getLoggerService())
     return self.picasaServer
Пример #38
0
    def _validateBlog(self, blog, validationReporter):
        zaccount = blog.getAccount()
        if not zaccount:
            # defect 534 work around - should not get here
            logger = getLoggerService()
            logger.error(u"Account information not available for Blog ID %s" %
                         blog.getId())  #$NON-NLS-1$
            validationReporter.addError(
                u"Blog Account",
                u"Account information not available for blog %s" %
                blog.getName())  #$NON-NLS-1$ #$NON-NLS-2$
            return

        username = zaccount.getAttribute(u"username")  #$NON-NLS-1$
        if not getNoneString(username):
            validationReporter.addError(
                u"Blog Account", u"Username is missing for blog %s" %
                blog.getName())  #$NON-NLS-1$ #$NON-NLS-2$
        cyppass = zaccount.getAttribute(u"password")  #$NON-NLS-1$
        if not getNoneString(cyppass):
            validationReporter.addError(
                u"Blog Account", u"Password is missing for blog %s" %
                blog.getName())  #$NON-NLS-1$ #$NON-NLS-2$
        else:
            password = None
            try:
                password = crypt.decryptCipherText(cyppass,
                                                   PASSWORD_ENCRYPTION_KEY)
            except:
                pass
            if not getNoneString(password):
                validationReporter.addError(
                    u"Blog Account",
                    u"Invalid password set for blog %s. Please set the blog account password."
                    % blog.getName())  #$NON-NLS-1$ #$NON-NLS-2$

        apiInfo = zaccount.getAPIInfo()
        url = apiInfo.getUrl()
        if not getNoneString(url):
            validationReporter.addError(
                u"Blog Account", u"Blog API URL is required for blog %s" %
                blog.getName())  #$NON-NLS-1$ #$NON-NLS-2$

        siteId = apiInfo.getType()
        if not getNoneString(siteId):
            validationReporter.addError(
                u"Blog Account", u"Blog API type is required for blog %s" %
                blog.getName())  #$NON-NLS-1$ #$NON-NLS-2$
Пример #39
0
 def __init__(self):
     self.id = None
     self.name = None
     self.startTime = ZSchemaDateTime()
     self.endTime = None
     self.error = None
     self.numWorkUnits = 0
     self.numCompletedWorkUnits = 0
     self.logLocation = None
     self.logFile = None
     self.running = False
     self.stopped = True
     self.cancelled = False
     self.lastMessage = None
     self.listeners = ZListenerSet()
     self.logger = getLoggerService()
Пример #40
0
 def __init__(self):
     self.id = None
     self.name = None
     self.startTime = ZSchemaDateTime()
     self.endTime = None
     self.error = None
     self.numWorkUnits = 0
     self.numCompletedWorkUnits = 0
     self.logLocation = None
     self.logFile = None
     self.running = False
     self.stopped = True
     self.cancelled = False
     self.lastMessage = None
     self.listeners = ZListenerSet()
     self.logger = getLoggerService()
Пример #41
0
 def _getPicasaServer(self):
     if not self.picasaServer:
         username = None
         password = None
         if u"username" in self.properties:  #$NON-NLS-1$
             username = getNoneString(
                 self.properties[u"username"])  #$NON-NLS-1$
         if not username:
             raise ZException(
                 u"Picasa web album account username is required."
             )  #$NON-NLS-1$
         if u"password" in self.properties:  #$NON-NLS-1$
             password = getNoneString(
                 self.properties[u"password"])  #$NON-NLS-1$
         if not password:
             raise ZException(
                 u"Picasa web album account password is required."
             )  #$NON-NLS-1$
         self.picasaServer = ZPicasaServer(username, password)
         self.picasaServer.setLogger(getLoggerService())
     return self.picasaServer
Пример #42
0
    u"""Returns the (temp) file path to png file representing the clipboard bitmap or None otherwise.
    If copyToResourceStore = true, then the tmp image file is copied to the resource store.
    """ #$NON-NLS-1$
    filepath = None
    bmp = getBitmapFromClipboard()
    if bmp:
        try:
            osutil = getOSUtil()
            tempDir = osutil.getSystemTempDirectory()
            name = generateFilename(u"zrclip",
                                    u".png")  #$NON-NLS-1$ #$NON-NLS-2$
            filepath = os.path.abspath(os.path.join(tempDir, name))
            bmp.SaveFile(filepath, wx.BITMAP_TYPE_PNG)
        except Exception, e:
            filepath = None
            getLoggerService().exception(e)
    if filepath and copyToResourceStore:
        try:
            # get resource store and add to it.
            resStore = getApplicationModel().getEngine().getService(
                IZAppServiceIDs.RESOURCE_STORE_SERVICE_ID)
            resEntry = resStore.addResource(filepath)
            if resEntry:
                # temp file was added to resource store, so, use the resource store path instead of temp file path.
                filepath = resEntry.getFilePath()
        except Exception, e:
            getLoggerService().exception(e)
    return filepath


# end getPngFileFromClipboard()
Пример #43
0
 def __init__(self, blog):
     self.blog = blog
     self.cancelled = False
     self.logger = getLoggerService()
Пример #44
0
 def logException(self, izBlogPublishHandler, exception):  #@UnusedVariable
     s = u"[EXCEPTION][%s] %s" % (
         izBlogPublishHandler.getName(), unicode(exception))  #$NON-NLS-1$
     self._debug(izBlogPublishHandler, s)
     if getLoggerService():
         getLoggerService().exception(exception)
Пример #45
0
    def _fetchTemplate(self, url, title, bodyStr):
        templateService = getApplicationModel().getService(IZBlogAppServiceIDs.TEMPLATE_SERVICE_ID)
        template = templateService.createTemplate()
        templateDir = template.getTemplateDirectory()
        try:
            webPageGetter = ZHttpWebpageGetter(url, templateDir, self)
            webPageGetter.setBasePathToken(IZTemplateConstants.TEMPLATE_BASE_TOKEN)
            rootFilePath = webPageGetter.saveAsWebpage()
            if self.cancelled:
                raise ZTemplateFetchCancelledException()

            rootXHtmlDoc = loadXhtmlDocumentFromFile(rootFilePath)
            rootXHtmlDom = rootXHtmlDoc.getDom()
            titleElems = self._findTitleElems(rootXHtmlDom, title)
            if not titleElems:
                return None
            contentElems = self._findContentElems(rootXHtmlDom, bodyStr)
            if not contentElems:
                return None

            indexAllUTFileName = os.path.join(templateDir, u"index-all-untrimmed.html") #$NON-NLS-1$
            rootXHtmlDom.save(indexAllUTFileName)

            if self.cancelled:
                raise ZTemplateFetchCancelledException()

            for titleElem in titleElems:
                titleElem.removeAllChildren()
                titleMarkerElem = rootXHtmlDom.createElement(u"ravenTitle", titleElem.getNamespaceUri()) #$NON-NLS-1$
                titleElem.appendChild(titleMarkerElem)

            for contentElem in contentElems:
                contentElem.removeAllChildren()
                contentMarkerElem = rootXHtmlDom.createElement(u"ravenBody", contentElem.getNamespaceUri()) #$NON-NLS-1$
                contentElem.appendChild(contentMarkerElem)

            rootFile = makeRelativePath(templateDir, rootFilePath)
            indexAllFileName = u"index-all.html" #$NON-NLS-1$
            indexBodyOnlyFileName = u"index-body.html" #$NON-NLS-1$
            indexTitleAndBodyFileName = u"index-titleBody.html" #$NON-NLS-1$

            template.setRootFileName(rootFile)
            template.setAllFileName(indexAllFileName)
            template.setBodyOnlyFileName(indexBodyOnlyFileName)
            template.setTitleAndBodyFileName(indexTitleAndBodyFileName)

            indexAll = os.path.join(templateDir, indexAllFileName)
            indexTitleAndBody = os.path.join(templateDir, indexTitleAndBodyFileName)
            indexBodyOnly = os.path.join(templateDir, indexBodyOnlyFileName)

            self.listener.grabFeedback(_extstr(u"templategrabber.TemplateDownloaded_Trimming")) #$NON-NLS-1$

            if self.cancelled:
                raise ZTemplateFetchCancelledException()

            # Save the 'all' variant
            rootXHtmlDom.save(indexAll)

            if self.cancelled:
                raise ZTemplateFetchCancelledException()

            # Trim the dom - remove everything except the title and body
            self._trimStageOne(titleElems, contentElems)
            rootXHtmlDom.save(indexTitleAndBody)

            if self.cancelled:
                raise ZTemplateFetchCancelledException()

            # Trim the dom again - remove everything except the body
            self._trimStageTwo(contentElems)
            rootXHtmlDom.save(indexBodyOnly)

            if self.cancelled:
                raise ZTemplateFetchCancelledException()

            self.listener.grabFeedback(_extstr(u"templategrabber.TemplateTrimmedAndSaved")) #$NON-NLS-1$

            return template
        except Exception, e:
            getLoggerService().exception(e)
            deleteDirectory(templateDir, True)
            raise e
Пример #46
0
    return bmp
# end getTextFromClipboard()

def getPngFileFromClipboard(copyToResourceStore=False):
    u"""Returns the (temp) file path to png file representing the clipboard bitmap or None otherwise.
    If copyToResourceStore = true, then the tmp image file is copied to the resource store.
    """ #$NON-NLS-1$
    filepath = None
    bmp = getBitmapFromClipboard()
    if bmp:
        try:
            osutil = getOSUtil()
            tempDir = osutil.getSystemTempDirectory()
            name = generateFilename(u"zrclip", u".png") #$NON-NLS-1$ #$NON-NLS-2$
            filepath = os.path.abspath( os.path.join(tempDir, name) )
            bmp.SaveFile(filepath, wx.BITMAP_TYPE_PNG)
        except Exception, e:
            filepath = None
            getLoggerService().exception(e)
    if filepath and copyToResourceStore:
        try:
            # get resource store and add to it.
            resStore = getApplicationModel().getEngine().getService(IZAppServiceIDs.RESOURCE_STORE_SERVICE_ID)
            resEntry = resStore.addResource(filepath)
            if resEntry:
                # temp file was added to resource store, so, use the resource store path instead of temp file path.
                filepath = resEntry.getFilePath()
        except Exception, e:
            getLoggerService().exception(e)
    return filepath
# end getPngFileFromClipboard()
Пример #47
0
 def onBlogEntryDropped(self, blogId, node):
     getLoggerService().debug(u"Dropped blog entry '%s' onto blog node '%s'." % (blogId, node.getBlog().getId())) #$NON-NLS-1$
     ZShowNotYetImplementedMessage(self)
Пример #48
0
 def _logSelectQueryTimings(self, sql, startTime, execTime, fetchTime, endTime):
     total = unicode(round((endTime - startTime) * 1000))
     execute = unicode(round((execTime - startTime) * 1000))
     fetch = unicode(round((fetchTime - execTime) * 1000))
     handle = unicode(round((endTime - fetchTime) * 1000))
     getLoggerService().debug(u"SQLSELECT (total=%s :: exec=%s, fetch=%s, handle=%s): %s" % (total, execute, fetch, handle, sql)) #$NON-NLS-1$
Пример #49
0
 def _doEndModal(self, code):
     try:
         self.EndModal(code)
         return self.bgTask.hasError()
     except Exception, e:
         getLoggerService().exception(e)
Пример #50
0
 def _logAnalyzeTimings(self, startTime, endTime):
     total = unicode(round((endTime - startTime) * 1000))
     getLoggerService().debug(u"SQLANALYZE (total=%s)" % total) #$NON-NLS-1$
Пример #51
0
 def rollback(self):
     getLoggerService().debug(u"rollback")  #$NON-NLS-1$
     self.populateWidgets()
Пример #52
0
 def _doEndModal(self, code):
     try:
         self.EndModal(code)
         return self.bgTask.hasError()
     except Exception, e:
         getLoggerService().exception(e)
Пример #53
0
 def _logDeleteTimings(self, sql, startTime, execTime, endTime):
     total = unicode(round((endTime - startTime) * 1000))
     execute = unicode(round((execTime - startTime) * 1000))
     getLoggerService().debug(u"SQLDELETE (total=%s :: exec=%s): %s" % (total, execute, sql)) #$NON-NLS-1$
Пример #54
0
 def onBlogEntryDropped(self, blogId, node):
     getLoggerService().debug(
         u"Dropped blog entry '%s' onto blog node '%s'." %
         (blogId, node.getBlog().getId()))  #$NON-NLS-1$
     ZShowNotYetImplementedMessage(self)