def run(self): success = False try: success = self._runTask() except Exception, e: zex = ZException(rootCause = e) #$NON-NLS-1$ zex.printStackTrace()
def _runTask(self): newValue = self.getPage()._getSiteUrl() # fire evt to start busy animation self.refreshPage(u"begin-autodiscover",newValue) #$NON-NLS-1$ rval = False try: # reset previous value self.getSession().setProperty(u"siteurl-page.discover-info", None) #$NON-NLS-1$ discoverInfo = self.getPage()._getModel().autodiscover(newValue) #print u"ZAutodiscoverTask info",discoverInfo #$NON-NLS-1$ FIXME (PJ) remove this debug line self.getSession().setProperty(u"siteurl-page.discover-info", discoverInfo) #$NON-NLS-1$ # cache successful results if discoverInfo and discoverInfo.siteId: cacheMap = self.getSession().getProperty(u"siteurl-page.discover-info-cache") #$NON-NLS-1$ if cacheMap is None: cacheMap = {} self.getSession().setProperty(u"siteurl-page.discover-info-cache", cacheMap) #$NON-NLS-1$ cacheMap[newValue] = discoverInfo rval = True except Exception, e: # FIXME (PJ) show friendly error messages # fire evt to show error message to user. zex = ZException(rootCause = e) data = (u"Auto discovery error", zex.getStackTrace(), zex) #$NON-NLS-1$ self.refreshPage(u"error-autodiscover", data) #$NON-NLS-1$
def __init__(self, rootCause = None, stage = u"", message = u"", code = 0): #$NON-NLS-1$ #$NON-NLS-2$ self.rootCause = rootCause self.code = code self.stage = stage if not rootCause: self.message = message else: self.message = unicode(rootCause) self.type = u"Error" #$NON-NLS-1$ self._analyze() ZException.__init__(self, self.message, self.rootCause)
def ZShowExceptionWithFeedback(parent, zexception): if not isinstance(zexception, ZException): zexception = ZException(rootCause=zexception) dlg = ZExceptionWithFeedbackDialog(parent, zexception) dlg.CentreOnParent() rval = dlg.ShowModal() dlg.Destroy() if parent is not None: parent.RemoveChild(dlg) if rval == wx.ID_OK: from zoundry.appframework.ui.util.feedbackutil import ZFeedbackUtil ZFeedbackUtil().doFeedback(parent, zexception.getMessage(), zexception.getStackTrace())
def _doRun(self): service = getApplicationModel().getService( IZBlogAppServiceIDs.PRODUCTS_SERVICE_ID) userPrefs = getApplicationModel().getUserProfile().getPreferences() zoundryId = userPrefs.getUserPreference( IZBlogAppUserPrefsKeys.ZOUNDRY_ID, None) if not zoundryId: zoundryId = u"*****@*****.**" #$NON-NLS-1$ self.logger.debug( u"Converting link %s using zoundry id %s." % (unicode(self.url), unicode(zoundryId))) #$NON-NLS-1$ self._fireWorkDoneEvent( 1, _extstr( u"blogeditoractions.Invoking_Zoundry_Service")) #$NON-NLS-1$ newUrl = service.convertProductLink(self.url, zoundryId) if newUrl: self.logger.debug(u"Link successfully converted to %s" % unicode(newUrl)) #$NON-NLS-1$ self._fireWorkDoneEvent( 1, _extstr(u"blogeditoractions.SuccessfullyConvertedLink" )) #$NON-NLS-1$ if not self.isCancelled(): self.zoundryProductUrl = newUrl else: raise ZException(_extstr( u"blogeditoractions.FailedToConvertLink")) #$NON-NLS-1$
def start(self, listener = _NULL_STARTUP_LISTENER): listener.engineStarting() # Get the list of service extension points. extensionPoints = self._getServiceExtensionPoints() listener.engineCreatingServices(len(extensionPoints)) # Create all of the IZService objects. createdServices = [] numFailed = 0 for extensionPoint in extensionPoints: extPointId = extensionPoint.getId() try: theClass = extensionPoint.loadClass() if not issubclass(theClass, IZService): raise ZEngineException(_extstr(u"engine.ErrorCreatingService") % extensionPoint.getClass()) #$NON-NLS-1$ theService = theClass() if not isinstance(theService, IZService): raise ZEngineException(_extstr(u"engine.ErrorCreatingService") % extensionPoint.getClass()) #$NON-NLS-1$ listener.engineServiceCreated(extPointId) createdServices.append( (extPointId, theService) ) except ZException, ze: listener.engineServiceCreationFailed(extPointId, ze.getStackTrace()) numFailed += 1 except Exception, e: listener.engineServiceCreationFailed(extPointId, ZException(rootCause = e).getStackTrace()) numFailed += 1
def setProperty(self, _xpath, value, autoCommit=True): u"""Sets a user or system property. Takes an xpath, value, and optional boolean flag 'system' which indicates whether to change the user or system properties. Raises a ValueError if the xpath is not a valid (already-existing) node or attribute.""" #$NON-NLS-1$ self.lock.acquire() node = self.getPropertyNode(_xpath) if not node: node = self.createPropertyNode(_xpath) if not node: raise ValueError if isinstance(value, unicode) or isinstance(value, str): node.setText(value) elif isinstance(value, ZElement): node.removeAllChildren() value = node.ownerDocument.importNode(value, True) node.appendChild(value) else: raise ZException(u"Unsupported value type for setProperty: %s" % unicode(type(value))) #$NON-NLS-1$ # Now save the files (pretty print) if autoCommit: self.saveProperties() self.lock.release() self._fireEvent(_xpath, value)
def _uploadStream(self, fileName, fileStream, metaData): #@UnusedVariable albumName = self._getAlbumName() if not albumName: raise ZException( u"LJ Fotobilder web album name is required.") #$NON-NLS-1$ fotoBilderUploadResult = self._getPhotoBilderServer().uploadFile( fileStream, gallery=albumName) if fotoBilderUploadResult: if fotoBilderUploadResult.getUploadPicResponseNode(): return ZUploadResponse( fotoBilderUploadResult.getUrl(), metaData=fotoBilderUploadResult.getUploadPicResponseNode()) else: return ZUploadResponse(fotoBilderUploadResult.getUrl()) else: raise ZException(u"LJ FotoBilder upload failed.") #$NON-NLS-1$
def listFiles(self, relativePath=None): #@UnusedVariable albumName = self._getAlbumName() if not albumName: raise ZException( u"Picasa web album name is required to list photos." ) #$NON-NLS-1$ albumEntry = self._getPicasaAlbumEntry(albumName) if not albumEntry: raise ZException( u"Can not list photos. Picasa web album '%s' does not exist." % albumName) #$NON-NLS-1$ rval = [] photoEntries = self._getPicasaServer().listPhotosByAlbumName( albumEntry.getAlbumName()) for entry in photoEntries: rval.append(entry.getTitle()) return rval
def main(): try: app = RavenApplication() app.run() except Exception, e: ZException(e).printStackTrace() # Need to do something here - show some kind of UI message. raise e
def execute(self, mediaStore, session): testImageName = u"z_raven_test_image.png" #$NON-NLS-1$ testImagePath = getApplicationModel().getResourceRegistry().getImagePath(u"images/common/ztest/%s" % testImageName) #$NON-NLS-1$ rval = None try: rval = mediaStore.upload(testImagePath, bypassRegistry = True) except Exception, e: raise ZException(_extstr(u"mediastorageztest.FailedToUploadTestFileError") % mediaStore.getName(), e) #$NON-NLS-1$
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$
def ZShowTemplateManager(): global TEMPLATE_MANAGER_WINDOW try: if TEMPLATE_MANAGER_WINDOW is None: TEMPLATE_MANAGER_WINDOW = ZTemplateManagerWindow(None) TEMPLATE_MANAGER_WINDOW.Show() TEMPLATE_MANAGER_WINDOW.Raise() return TEMPLATE_MANAGER_WINDOW except Exception, e: ZShowExceptionMessage(None, ZException(u"Error opening Background Task Manager", e)) #$NON-NLS-1$
def deleteDirectory(path, alsoDeleteDir=True, deleteFilter=EVERYTHING_FILTER): u"""deleteDirectory(string, boolean?) -> None Recursively deletes the contents of the given directory. If the alsoDeleteDir boolean flag is True, then the directory itself is also deleted. If it is False, then only the contents of the directory are deleted.""" #$NON-NLS-1$ # If the path doesn't exist, just return 0. if not os.path.exists(path): return 0 # Throw if the root path is given as the param! if path == u"/" or path.endswith(u":/") or path.endswith( u":\\"): #$NON-NLS-3$ #$NON-NLS-2$ #$NON-NLS-1$ raise ZException( _extstr(u"fileutil.FailedToDeleteRootPathMsg")) #$NON-NLS-1$ # If the path exists, but is not a directory, that's an error. if not os.path.isdir(path): raise ZException(_extstr(u"fileutil.InvalidDirPath") % path) #$NON-NLS-1$ try: count = 0 files = os.listdir(path) for file in files: fullFile = os.path.join(path, file) if os.path.isfile(fullFile): if deleteFilter(fullFile): deleteFile(fullFile) count = count + 1 else: shouldDeleteDir = deleteFilter(fullFile) count = count + deleteDirectory(fullFile, shouldDeleteDir, deleteFilter) if alsoDeleteDir: os.rmdir(path) return count except Exception, e: raise ZException(_extstr(u"fileutil.DirDeleteFailed") % path, e) #$NON-NLS-1$
def deleteFile(path): # If the path does not exist, just return. if not os.path.exists(path): return # If the path exists but is not a file, that's an error. if not os.path.isfile(path): raise ZException(_extstr(u"fileutil.InvalidFilePath") % path) #$NON-NLS-1$ os.remove(path)
def _getPhotoBilderServer(self): if not self.fotobilderServer: url = None username = None password = None if u"url" in self.properties: #$NON-NLS-1$ url = self.properties[u"url"] #$NON-NLS-1$ if u"username" in self.properties: #$NON-NLS-1$ username = self.properties[u"username"] #$NON-NLS-1$ else: raise ZException(u"LJ FotoBilder account username is required." ) #$NON-NLS-1$ if u"password" in self.properties: #$NON-NLS-1$ password = self.properties[u"password"] #$NON-NLS-1$ else: raise ZException(u"LJ FotoBilder account password is required." ) #$NON-NLS-1$ self.fotobilderServer = ZFotoBilderServer(username, password, url) return self.fotobilderServer
def _copyAspellDirToTemp(self, spellingDir): osutil = getOSUtil() tempDir = osutil.getSystemTempDirectory() if not os.path.isdir(tempDir): raise ZException(u"System temp directory not found.") #$NON-NLS-1$ tempSpellingDir = os.path.join(tempDir, u"_RavenSpellcheck_tmp") #$NON-NLS-1$ if not os.path.exists(tempSpellingDir): os.mkdir(tempSpellingDir) copyFiles(spellingDir, tempSpellingDir) return tempSpellingDir
def run(self): self.done = False try: if self.runnable: self.runnable.run() else: self._run() except Exception, e: self._handleException( ZException(_extstr(u"zthread.UnexpectedErrorInThread"), e)) #$NON-NLS-1$
def _runTask(self): # fire evt to start busy animation self.refreshPage(u"begin-listblogs") #$NON-NLS-1$ rval = False try: blogs = self.getPage()._getModel().listBlogs(self.siteId, self.username, self.password, self.apiUrl) idx = 0 idBlogList = [] for blog in blogs: idBlogList.append( (idx, blog) ) idx = idx + 1 self.getSession().setProperty(u"apiinfo-page.modifykey", self.key) #$NON-NLS-1$ self.getSession().setProperty(u"apiinfo-page.id-bloglist", idBlogList) #$NON-NLS-1$ rval = True except Exception, e: # FIXME (PJ) show friendly error messages zex = ZException(rootCause = e) data = (u"Error fetching list of blogs", zex.getStackTrace(), zex) #$NON-NLS-1$ # fire evt to show error message to user. self.refreshPage(u"error-listblogs", data) #$NON-NLS-1$
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
def _verifyHttpURL(self, url): tempFilePath = os.path.join(getApplicationModel().getUserProfile().getTempDirectory(), u"tmp_url_mstore_ztest.bin") #$NON-NLS-1$ downloader = ZHttpBinaryFileDownload(url, tempFilePath) try: downloader.send() ct = downloader.getContentType() numBytes = downloader.getResponse() if (ct == u"image/png") and (numBytes == 222): #$NON-NLS-1$ raise ZException(_extstr(u"mediastorageztest.FileStillExistsError") % url) #$NON-NLS-1$ finally: if os.path.isfile(tempFilePath): os.remove(tempFilePath)
def _getAccountDirList(self): accountDirPath = os.path.join(self.pathToJoeyProfile, u"accounts") #$NON-NLS-1$ fullDirNames = [] try: # get the account.xml ("table of contents") file into a dom accountsTocXmlFileName = os.path.join(accountDirPath, self._getAccountTocXmlFilename() ) #$NON-NLS-1$ if not os.path.exists(accountsTocXmlFileName): return fullDirNames tocDom = ZDom() tocDom.load(accountsTocXmlFileName) accIdNodes = tocDom.selectNodes(u"/blog-accounts/blog-account/@id") #$NON-NLS-1$ for accIdNode in accIdNodes: accId = accIdNode.getText() fullPath = os.path.join(accountDirPath, accId) if os.path.isdir(fullPath): accountXmlFileName = os.path.join(fullPath, u"account.xml") #$NON-NLS-1$ if os.path.isfile(accountXmlFileName): fullDirNames.append( (fullPath, accountXmlFileName) ) except Exception, e: ze = ZException(e) ze.printStackTrace()
def ZShowBackgroundTaskManager(): global BGTASK_MANAGER_WINDOW try: if BGTASK_MANAGER_WINDOW is None: BGTASK_MANAGER_WINDOW = ZBackgroundTaskManagerWindow(None) BGTASK_MANAGER_WINDOW.Show() BGTASK_MANAGER_WINDOW.Raise() except Exception, e: ZShowExceptionMessage(None, ZException( u"Error opening Background Task Manager", e)) #$NON-NLS-1$
def __repr__(self): try: rval = u"Omega Node\n" #$NON-NLS-1$ if self.plugin: id = self.plugin.getId() rval = u"\n" + id.rjust(len(id) + self.depth * 3) #$NON-NLS-1$ for child in self.children: rval = rval + child.__repr__() return rval except Exception, e: return ZException(rootCause=e).getStackTrace()
def trim(self): xhtmlDoc = loadXhtmlDocumentFromFile(self._getRootFile()) xhtmlDom = xhtmlDoc.getDom() vizzy = ZTemplateBodyFindingVisitor() vizzy.visit(xhtmlDom) elem = vizzy.getResult() if elem is None: raise ZException( u"Failed to find Raven template marker content.") #$NON-NLS-1$ self._doTrim(elem) self._save(xhtmlDom)
def _uploadStream(self, fileName, fileStream, metaData): #@UnusedVariable u"""_uploadStream(string, stream, ZElement) -> IZUploadResponse Called to upload a file stream to the remote media storage. Returns the URL of the uploaded file.""" #$NON-NLS-1$ photoEditMediaLink = self._getEditMediaLinkFromMetaData(metaData) self._logDebug(u"upload file %s" % fileName) #$NON-NLS-1$ self._logDebug(u"photoEditMediaLink is %s" % photoEditMediaLink) #$NON-NLS-1$ photoEntry = None if photoEditMediaLink: # update existing file. photoEntry = self._getPicasaServer().updatePhotoFile( photoEditMediaLink, fileStream) else: # add new photo albumName = self._getAlbumName() self._logDebug(u"upload albumName %s" % albumName) #$NON-NLS-1$ if not getNoneString(albumName): self._logError( u"Picasa web album name is required.") #$NON-NLS-1$ raise ZException( u"Picasa web album name is required.") #$NON-NLS-1$ albumEntry = self._getPicasaAlbumEntry(albumName) if not albumEntry: self._logError(u"Picasa web album '%s' does not exist." % albumName) #$NON-NLS-1$ raise ZException(u"Picasa web album '%s' does not exist." % albumName) #$NON-NLS-1$ photoEntry = self._getPicasaServer().addPhotoFile( albumEntry.getAlbumName(), fileStream) if not photoEntry: self._logError(u"Picasa web album upload failed for file %s" % fileName) #$NON-NLS-1$ raise ZException(u"Picasa web album upload failed for file %s" % fileName) #$NON-NLS-1$ return ZUploadResponse(photoEntry.getUrl(), metaData=photoEntry.getNode())
def doCommand(self): u"""Sequentially invokes doCommand on each of the commands in the collection.""" #$NON-NLS-1$ for command in self.getCommands(): if not self.isCancelled(): try: command.doCommand() except Exception, e: self._handleException( ZException( _extstr(u"zcommand.UnexpectedErrorInDoCommand"), e)) #$NON-NLS-1$ except: self._handleException(
def undoCommand(self): u"""Sequentially (in reverse order) invokes undoCommand on each of the commands in the collection.""" #$NON-NLS-1$ cmdList = [] cmdList.extend(self.getCommands()) cmdList.reverse() for command in cmdList: try: command.undoCommand() except Exception, e: self._handleException( ZException( _extstr(u"zcommand.UnexpectedErrorInUnDoCommand"), e)) #$NON-NLS-1$ except:
class RavenApplicationStartup(ZThread, IZPluginRegistryListener, IZEngineStartupListener): def __init__(self, applicationModel, listener): self.startupErrors = [] self.logBuff = StringIO() self.applicationModel = applicationModel self.listener = listener ZThread.__init__(self, name=u"RavenApplicationStartup") #$NON-NLS-1$ # end __init__() def _run(self): try: # First, load the plugins self.listener.rasStart(NUM_STARTUP_TASKS) pluginRegistry = ZPluginRegistry( self.applicationModel.getSystemProfile(), self.applicationModel.getUserProfile()) pluginRegistry.loadPlugins(self) self.applicationModel.setPluginRegistry(pluginRegistry) self.applicationModel.setActionRegistry(ZActionRegistry()) registerBlogAppActions(self.applicationModel.getActionRegistry()) # Next, create and start the engine engine = ZEngine(self.applicationModel) self.applicationModel.setEngine(engine) engine.start(self) self.applicationModel.setLogger( engine.getService(IZAppServiceIDs.LOGGER_SERVICE_ID)) # hook up logger with auth manager ZAuthenticationManager().setLogger( engine.getService(IZAppServiceIDs.LOGGER_SERVICE_ID)) except ZException, ze: ze.printStackTrace() self.startupErrors.append( _extstr(u"startup.ErrorDuringStartupMsg") % ze.getMessage()) #$NON-NLS-1$ self.logBuff.write( _extstr(u"startup.ErrorDuringStartupMsg") % ze.getStackTrace()) #$NON-NLS-1$ except Exception, e: ze = ZException(rootCause=e) ze.printStackTrace() self.startupErrors.append( _extstr(u"startup.ErrorDuringStartupMsg") % unicode(e)) #$NON-NLS-1$ self.logBuff.write( _extstr(u"startup.ErrorDuringStartupMsg") % ze.getStackTrace()) #$NON-NLS-1$
def __init__(self, date=None): param = date if not date: param = getCurrentUtcDateTime() if isinstance(param, str) or isinstance(param, unicode): self._initFromString(param) elif isinstance(param, long) or isinstance(param, int): self._initFromLongMs(param) elif isinstance(param, datetime): self.dateTime = convertToUtcDateTime(param) else: raise ZException(_extstr( u"schematypes.SchemaDateTimeFormatError")) #$NON-NLS-1$
def doCallback(self, callbackMethodName, argumentSequence=None): self._acquireMutex() try: if argumentSequence is None: argumentSequence = [] for listener in self: try: method = getattr(listener, callbackMethodName) method(*argumentSequence) except ZException, ze: raise ze except Exception, e: raise ZException(e)
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
def _runTask(self): # fire evt to start busy animation self.refreshPage(u"begin-listblogs") #$NON-NLS-1$ rval = False try: blogs = self.getPage()._getModel().listBlogs( self.siteId, self.username, self.password, self.apiUrl) idx = 0 idBlogList = [] for blog in blogs: idBlogList.append((idx, blog)) idx = idx + 1 self.getSession().setProperty(u"apiinfo-page.modifykey", self.key) #$NON-NLS-1$ self.getSession().setProperty(u"apiinfo-page.id-bloglist", idBlogList) #$NON-NLS-1$ rval = True except Exception, e: # FIXME (PJ) show friendly error messages zex = ZException(rootCause=e) data = (u"Error fetching list of blogs", zex.getStackTrace(), zex ) #$NON-NLS-1$ # fire evt to show error message to user. self.refreshPage(u"error-listblogs", data) #$NON-NLS-1$
def getFileMetaData(fileName): u"""getFileMetaData(string) -> (string, string, int, ZSchemaDateTime) Called to get meta information about a file. Pass in the file name and get back a tuple of information: (shortFileName, abs file name, file size, timestamp).""" #$NON-NLS-1$ if not os.path.isfile(fileName): raise ZException(_extstr(u"fileutil.NotAValidFileError") % fileName) #$NON-NLS-1$ shortName = os.path.basename(fileName) absPath = os.path.abspath(fileName) status = os.lstat(absPath) size = status[stat.ST_SIZE] modEpoch = status[stat.ST_MTIME] modifiedTimeDT = getDateTimeFromEpoch(modEpoch) return (shortName, absPath, size, ZSchemaDateTime(modifiedTimeDT))
class ZHttpWebpageGetter: def __init__(self, url, outputDir, listener): self.url = url self.outputDir = os.path.abspath(outputDir) self.listener = listener self.resourceMap = {} self.downloadedHrefs = ZSortedSet() self.resourcesToFixup = ZSortedSet() self.basePathToken = None self.baseHref = None self.imagesDir = os.path.join(self.outputDir, u"images") #$NON-NLS-1$ if not os.path.exists(self.imagesDir): os.makedirs(self.imagesDir) self.cssDir = os.path.join(self.outputDir, u"css") #$NON-NLS-1$ if not os.path.exists(self.cssDir): os.makedirs(self.cssDir) self.otherDir = os.path.join(self.outputDir, u"other") #$NON-NLS-1$ if not os.path.exists(self.otherDir): os.makedirs(self.otherDir) self.cookieReg = ZCookieReg() if self.listener is None: self.listener = IZHttpWebpageGetterListener() # end __init__() def setBasePathToken(self, token): self.basePathToken = token # end setBasePathToken() def saveAsWebpage(self): self.listener.onWebpageGetterStart() rootFile = None try: rootFile = self._saveAsWebpage() except ZException, ze: self.listener.onWebpageGetterError(ze) raise ze except Exception, e: ze = ZException(rootCause=e) self.listener.onWebpageGetterError(ze) raise ze
def loadPlugins(self, listener=None): if not listener: listener = IZPluginRegistryListener() self.listener = listener pluginDirectories = self._getPluginDirectories() self.listener.pluginsLoading(len(pluginDirectories)) # Go through all of the plugin directories and load each plugin. The end result is a # list of ZPlugin objects. totalFailed = 0 pluginMap = {} for pluginDirectory in pluginDirectories: self.listener.pluginLoading(os.path.basename(pluginDirectory)) try: plugin = ZPlugin(pluginDirectory) if pluginMap.has_key(plugin.getId()): # plugin already exists. # Check for new versions of plug-ins as well as duplicate versions prevPlugin = pluginMap[plugin.getId()] v1 = plugin.getVersion() v2 = prevPlugin.getVersion() if v1 > v2: # new plugin is the latest version pluginMap[plugin.getId()] = plugin elif v1 == v2: # new plugin and old plug have same version id -> duplicate plugin id error raise ZAppFrameworkException( _extstr(u"plugin.DuplicatePluginId") % plugin.getId()) #$NON-NLS-1$ elif v1 < v2: # prevPlugin version number is newer. Do nothing (to keep the prevPlugin) pass else: pluginMap[plugin.getId()] = plugin self.listener.pluginLoaded(plugin.getId()) except ZException, ze: self.listener.pluginFailed(os.path.basename(pluginDirectory), ze.getStackTrace()) totalFailed += 1 except Exception, e: self.listener.pluginFailed( os.path.basename(pluginDirectory), ZException(rootCause=e).getStackTrace()) totalFailed += 1
def _reportException(self, exception): if not isinstance(exception, ZException): exception = ZException(_extstr(u"backgroundtaskimpl.UnexpectedBGTaskError") % self.getName(), exception) #$NON-NLS-1$ self.logger.exception(exception) self._raiseError(exception.getMessage(), exception.getStackTrace())
def __init__(self): ZException.__init__(self)
def __init__(self, message, rootCause = None): ZException.__init__(self, message, rootCause)
def __init__(self, message = None, rootCause = None): #$NON-NLS-1$ #$NON-NLS-2$ ZException.__init__(self, message, rootCause)