def createTarFile(self, dotScene): tar = tarfile.open(self.file, 'w:gz') scenefilename = self.file[:-4] tar.add(scenefilename) relativepath = MESH_MODEL_FOLDER.replace("/", os.sep) allreadyread = [] for k, oNode in dotScene.dotscenemanager.nodes.iteritems(): #print oNode.entityMeshFile print k pathToFile = relativepath + os.sep + oNode.entityMeshFile if (allreadyread.__contains__(pathToFile) == False): print pathToFile allreadyread.append(pathToFile) tar.add(pathToFile) materialfile = pathToFile[:-5] + ".material" if (self.fileExists(materialfile) == True): tar.add(materialfile) tar.close()
def createTarFile(self, dotScene): tar = tarfile.open(self.file, 'w:gz') scenefilename = self.file[:-4] tar.add(scenefilename) relativepath = MESH_MODEL_FOLDER.replace("/", os.sep) allreadyread = [] for k, oNode in dotScene.dotscenemanager.nodes.iteritems(): #print oNode.entityMeshFile print k pathToFile = relativepath + os.sep + oNode.entityMeshFile if(allreadyread.__contains__(pathToFile)==False): print pathToFile allreadyread.append(pathToFile) tar.add(pathToFile) materialfile = pathToFile[:-5] + ".material" if(self.fileExists(materialfile)==True): tar.add(materialfile) tar.close()
def copyfiles(self, ds): # Copy files to temp dir self.appDataUploadFolder = r.getApplicationDataDirectory( ) + os.sep + TEMP_UPLOAD_FOLDER if (os.path.exists(self.appDataUploadFolder) == False): os.mkdir(self.appDataUploadFolder) else: #os.remove(self.appDataUploadFolder+os.sep+"*.*") #shutil.rmtree("./" + self.appDataUploadFolder) shutil.rmtree(self.appDataUploadFolder) time.sleep(1) os.mkdir(self.appDataUploadFolder) relativepath = MESH_MODEL_FOLDER.replace("/", os.sep) # print ds.fileName # split = ds.fileName.split('/') # name = split[-1] name = self.nameFromFilepath(ds.fileName) dstSceneFile = self.appDataUploadFolder + os.sep + name # if exists copy <scene_name>.material file to upload package sceneMaterialFilePath = ds.fileName[:-6] + ".material" if (self.fileExists(sceneMaterialFilePath) == True): materialname = self.nameFromFilepath(sceneMaterialFilePath) dstSceneMaterialFile = self.appDataUploadFolder + os.sep + materialname shutil.copyfile(sceneMaterialFilePath, dstSceneMaterialFile) # copy images in scene material file self.copyTextures(sceneMaterialFilePath, TEXTURE_FOLDER) saver = SceneSaver() saver.save(dstSceneFile, ds.dotscenemanager.nodes) for k, oNode in ds.dotscenemanager.nodes.iteritems(): #print k dstFile = self.appDataUploadFolder + os.sep + oNode.entityMeshFile # try first load from scene folder sceneFilePath = os.path.dirname( ds.fileName) + os.sep + oNode.entityMeshFile pathToFile = relativepath + os.sep + oNode.entityMeshFile materialfile = '' if (self.fileExists(sceneFilePath)): shutil.copyfile(sceneFilePath, dstFile) materialfile = sceneFilePath[:-5] + ".material" elif (self.fileExists(pathToFile)): shutil.copyfile(pathToFile, dstFile) materialfile = pathToFile[:-5] + ".material" #print materialfile if (self.fileExists(materialfile) == True): dstFile = self.appDataUploadFolder + os.sep + oNode.entityMeshFile[: -5] + ".material" shutil.copyfile(materialfile, dstFile) self.copyTextures(materialfile, TEXTURE_FOLDER) # check material folder materialfile2 = MATERIAL_FOLDER + os.sep + oNode.entityMeshFile[: -5] + ".material" #print materialfile2 if (self.fileExists(materialfile2) == True): dstFile = self.appDataUploadFolder + os.sep + oNode.entityMeshFile[: -5] + ".material" shutil.copyfile(materialfile2, dstFile) self.copyTextures(materialfile2, MATERIAL_FOLDER) #copy collision mesh if specified if (oNode.entityCollisionFile != None and oNode.entityCollisionFile != ""): collisionPath = os.path.dirname( materialfile) + os.sep + oNode.entityCollisionFile if (self.fileExists(collisionPath)): dstFile = self.appDataUploadFolder + os.sep + oNode.entityCollisionFile shutil.copyfile(collisionPath, dstFile) else: print "Collision file specified, but not found"
def copyfiles(self, ds): # Copy files to temp dir if (os.path.exists(TEMP_UPLOAD_FOLDER) == False): os.mkdir(TEMP_UPLOAD_FOLDER) else: #os.remove(TEMP_UPLOAD_FOLDER+os.sep+"*.*") shutil.rmtree("./" + TEMP_UPLOAD_FOLDER) time.sleep(1) os.mkdir(TEMP_UPLOAD_FOLDER) relativepath = MESH_MODEL_FOLDER.replace("/", os.sep) # print ds.fileName # split = ds.fileName.split('/') # name = split[-1] name = self.nameFromFilepath(ds.fileName) dstSceneFile = TEMP_UPLOAD_FOLDER + os.sep + name # if exists copy <scene_name>.material file to upload package sceneMaterialFilePath = ds.fileName[:-6] + ".material" if (self.fileExists(sceneMaterialFilePath) == True): materialname = self.nameFromFilepath(sceneMaterialFilePath) dstSceneMaterialFile = TEMP_UPLOAD_FOLDER + os.sep + materialname shutil.copyfile(sceneMaterialFilePath, dstSceneMaterialFile) # copy images in scene material file self.copyTextures(sceneMaterialFilePath, TEXTURE_FOLDER) saver = SceneSaver() saver.save(dstSceneFile, ds.dotscenemanager.nodes) for k, oNode in ds.dotscenemanager.nodes.iteritems(): #print k dstFile = TEMP_UPLOAD_FOLDER + os.sep + oNode.entityMeshFile # try first load from scene folder sceneFilePath = os.path.dirname( ds.fileName) + os.sep + oNode.entityMeshFile pathToFile = relativepath + os.sep + oNode.entityMeshFile materialfile = '' if (self.fileExists(sceneFilePath)): shutil.copyfile(sceneFilePath, dstFile) materialfile = sceneFilePath[:-5] + ".material" elif (self.fileExists(pathToFile)): shutil.copyfile(pathToFile, dstFile) materialfile = pathToFile[:-5] + ".material" #print materialfile if (self.fileExists(materialfile) == True): dstFile = TEMP_UPLOAD_FOLDER + os.sep + oNode.entityMeshFile[: -5] + ".material" shutil.copyfile(materialfile, dstFile) self.copyTextures(materialfile, TEXTURE_FOLDER) # check material folder materialfile2 = MATERIAL_FOLDER + os.sep + oNode.entityMeshFile[: -5] + ".material" #print materialfile2 if (self.fileExists(materialfile2) == True): dstFile = TEMP_UPLOAD_FOLDER + os.sep + oNode.entityMeshFile[: -5] + ".material" shutil.copyfile(materialfile2, dstFile) self.copyTextures(materialfile2, MATERIAL_FOLDER)
def copyfiles(self, ds): # Copy files to temp dir self.appDataUploadFolder=r.getApplicationDataDirectory()+ os.sep + TEMP_UPLOAD_FOLDER if(os.path.exists(self.appDataUploadFolder)==False): os.mkdir(self.appDataUploadFolder) else: #os.remove(self.appDataUploadFolder+os.sep+"*.*") #shutil.rmtree("./" + self.appDataUploadFolder) shutil.rmtree(self.appDataUploadFolder) time.sleep(1) os.mkdir(self.appDataUploadFolder) relativepath = MESH_MODEL_FOLDER.replace("/", os.sep) # print ds.fileName # split = ds.fileName.split('/') # name = split[-1] name = self.nameFromFilepath(ds.fileName) dstSceneFile = self.appDataUploadFolder + os.sep + name # if exists copy <scene_name>.material file to upload package sceneMaterialFilePath=ds.fileName[:-6] + ".material" if(self.fileExists(sceneMaterialFilePath)==True): materialname = self.nameFromFilepath(sceneMaterialFilePath) dstSceneMaterialFile = self.appDataUploadFolder + os.sep + materialname shutil.copyfile(sceneMaterialFilePath, dstSceneMaterialFile); # copy images in scene material file self.copyTextures(sceneMaterialFilePath, TEXTURE_FOLDER) saver = SceneSaver() saver.save(dstSceneFile, ds.dotscenemanager.nodes) for k, oNode in ds.dotscenemanager.nodes.iteritems(): #print k dstFile = self.appDataUploadFolder + os.sep + oNode.entityMeshFile # try first load from scene folder sceneFilePath = os.path.dirname(ds.fileName) + os.sep + oNode.entityMeshFile pathToFile = relativepath + os.sep + oNode.entityMeshFile materialfile = '' if(self.fileExists(sceneFilePath)): shutil.copyfile(sceneFilePath, dstFile) materialfile = sceneFilePath[:-5] + ".material" elif(self.fileExists(pathToFile)): shutil.copyfile(pathToFile, dstFile) materialfile = pathToFile[:-5] + ".material" #print materialfile if(self.fileExists(materialfile)==True): dstFile = self.appDataUploadFolder + os.sep + oNode.entityMeshFile[:-5] + ".material" shutil.copyfile(materialfile, dstFile) self.copyTextures(materialfile, TEXTURE_FOLDER) # check material folder materialfile2 = MATERIAL_FOLDER + os.sep + oNode.entityMeshFile[:-5] + ".material" #print materialfile2 if(self.fileExists(materialfile2)==True): dstFile = self.appDataUploadFolder + os.sep + oNode.entityMeshFile[:-5] + ".material" shutil.copyfile(materialfile2, dstFile) self.copyTextures(materialfile2, MATERIAL_FOLDER) #copy collision mesh if specified if(oNode.entityCollisionFile!=None and oNode.entityCollisionFile!=""): collisionPath = os.path.dirname(materialfile) + os.sep + oNode.entityCollisionFile if(self.fileExists(collisionPath)): dstFile = self.appDataUploadFolder + os.sep + oNode.entityCollisionFile shutil.copyfile(collisionPath, dstFile) else: print "Collision file specified, but not found"