def findNewsDir(self): """Returns the directory string for news content. Returns None if it cant find the directory """ if self.NewsOverHttp: # If we're running news-over-http, we dump the news into a # staging directory. return self.NewsStageDir searchPath = DSearchPath() if AppRunnerGlobal.appRunner: # In the web-publish runtime, it will always be here: searchPath.appendDirectory( Filename.expandFrom('$TT_3_5_ROOT/phase_3.5/models/news')) else: # In the launcher or dev environment, look here: basePath = os.path.expandvars('$TTMODELS') or './ttmodels' searchPath.appendDirectory( Filename.fromOsSpecific(basePath + '/built/' + self.NewsBaseDir)) searchPath.appendDirectory(Filename(self.NewsBaseDir)) pfile = Filename(self.NewsIndexFilename) found = vfs.resolveFilename(pfile, searchPath) if not found: self.notify.warning('findNewsDir - no path: %s' % self.NewsIndexFilename) self.setErrorMessage(TTLocalizer.NewsPageErrorDownloadingFile % self.NewsIndexFilename) return None self.notify.debug("found index file %s" % pfile) realDir = pfile.getDirname() return realDir
def cogExists(filePrefix): searchPath = DSearchPath() if AppRunnerGlobal.appRunner: searchPath.appendDirectory( Filename.expandFrom('$TT_3_5_ROOT/phase_3.5')) else: basePath = os.path.expandvars("$TTMODELS") or "./ttmodels" searchPath.appendDirectory( Filename.fromOsSpecific(basePath + "/built/phase_3.5")) filePrefix = filePrefix.strip("/") pfile = Filename(filePrefix) found = vfs.resolveFilename(pfile, searchPath) if not found: return False return True