def simulation(filename): scenes_folder = os.walk(app.node.scenes_root) scenes = [] for addr, dirs, files in scenes_folder: for file in files: if filename in file: with open(addr+'/'+file,'r') as f: app.node.scene = Scene.fromDict(json.load(f)) for worker in app.node.workers: response = requests.post(('http://%s:%s/api/internal/worker/scene/init/' + filename) % (worker.ip, worker.port)) return render_template("simulation.html")
def scene_init(filename): scenes_folder = os.walk(app.node.scenes_root) scenes = [] for addr, dirs, files in scenes_folder: for file in files: if filename in file: with open(addr+'/'+file,'r') as f: app.node.scene = Scene.fromDict(json.load(f)) app.node.scene.addObject(Fluid(32)) app.image = Image(app.node.scene.frameWidth, app.node.scene.frameHeight) return ok()
def test_deserialization(self): print("\nScene deserialization", end="") obj_cnt = 10 light_cnt = 2 camera_cnt = 1 scene = create_scene_sample(camera_cnt, obj_cnt, light_cnt) dict = json.loads(repr(scene)) s = Scene.fromDict(dict) self.assertEqual(s.name, "example") self.assertEqual(s.frameWidth, 800) self.assertEqual(s.frameHeight, 600) self.assertEqual(s.objCnt, obj_cnt) self.assertEqual(s.lightCnt, light_cnt) self.assertEqual(s.camCnt, camera_cnt)