def downloadNextFile(self, task): while self.nextNewsFile < len(self.newsFiles) and 'aaver' in self.newsFiles[self.nextNewsFile]: self.nextNewsFile += 1 if self.nextNewsFile >= len(self.newsFiles): self.notify.info('Done downloading news.') self.percentDownloaded = 1 del self.newsFiles del self.nextNewsFile del self.newsUrl del self.newsDir del self.ch del self.url if hasattr(self, 'filename'): del self.filename self.redownloadingNews = False if self.active: self.parseNewsContent() return task.done self.percentDownloaded = float(self.nextNewsFile) / float(len(self.newsFiles)) self.filename = self.newsFiles[self.nextNewsFile] self.nextNewsFile += 1 self.url = self.newsUrl + self.filename localFilename = Filename(self.newsDir, self.filename) self.notify.info('testing for %s' % localFilename.getFullpath()) doc = DocumentSpec(self.url) if self.filename in self.newsCache: size, date = self.newsCache[self.filename] if date and localFilename.exists() and (size == 0 or localFilename.getFileSize() == size): doc.setDate(date) doc.setRequestMode(doc.RMNewer) self.ch.beginGetDocument(doc) self.ch.downloadToFile(localFilename) taskMgr.remove(self.RedownloadTaskName) taskMgr.add(self.downloadCurrentFileTask, self.RedownloadTaskName)
def getMaterial(filename): global MaterialRefs filename = Filename(filename) fullpath = filename.getFullpath() if not fullpath.endswith(".mat"): fullpath += ".mat" fullpath = fullpath.lower() if fullpath in MaterialRefs: ref = MaterialRefs[fullpath] else: ref = MaterialReference(Filename(fullpath)) MaterialRefs[fullpath] = ref return ref
if not isdir(self.writePath): self.debug("Creating temp path, as it does not exist yet") try: os.makedirs(self.writePath, 0777) except Exception, msg: self.error("Failed to create temp path:",msg) import sys sys.exit(0) # Mount the pipeline temp path self.debug("Mounting",self.writePath,"as PipelineTemp/") vfs.mountLoop(self.writePath, 'PipelineTemp/', 0) # #pragma include "something" searches in current directory first, # and then on the model-path. Append the Shader directory to the modelpath # to ensure the shader includes can be found. base_path = Filename(self.basePath) getModelPath().appendDirectory(join(base_path.getFullpath(), 'Shader')) # Add the pipeline root directory to the model path aswell getModelPath().appendDirectory(base_path.getFullpath()) # Append the write path to the model directory to make pragma include # find the ShaderAutoConfig.include write_path = Filename(self.writePath) getModelPath().appendDirectory(write_path.getFullpath()) def unmount(self): """ Unmounts the VFS """ raise NotImplementedError()
try: os.makedirs(self.writePath, 0777) except Exception, msg: self.error("Failed to create temp path:", msg) import sys sys.exit(0) # Mount the pipeline temp path self.debug("Mounting", self.writePath, "as PipelineTemp/") vfs.mountLoop(self.writePath, 'PipelineTemp/', 0) # #pragma include "something" searches in current directory first, # and then on the model-path. Append the Shader directory to the modelpath # to ensure the shader includes can be found. base_path = Filename(self.basePath) self.modelPaths.append(join(base_path.getFullpath(), 'Shader')) # Add the pipeline root directory to the model path aswell self.modelPaths.append(base_path.getFullpath()) # Append the write path to the model directory to make pragma include # find the ShaderAutoConfig.include write_path = Filename(self.writePath) self.modelPaths.append(write_path.getFullpath()) for pth in self.modelPaths: getModelPath().appendDirectory(pth) def unmount(self): """ Unmounts the VFS """ raise NotImplementedError()