def __init__(self): Component.__init__(self) self.worldstream = None #self.worldstream = r.getServerConnection() self.queue = Queue.Queue() self.window = EstateManagementWindow(self, self.queue) self.uievents = UIEventManagement(self.window) self.rexlogic = r.getRexLogic() self.appdatafolder = "" try: self.appdatafolder = r.getApplicationDataDirectory() except: r.logInfo("Unexpected error:", sys.exc_info()[0]) self.rexlogic.connect("OnIncomingEstateOwnerMessage(QVariantList)", self.onEstateOwnerMessage) self.ents = [] self.managers = {} self.banned = {} self.accesslist = {} self.publicestate = True self.nameToUuidMapCache = {} self.savedusers = {} #self.estatesettings = EstateSettings(self.worldstream, self) self.estatesettings = None
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 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"