def save(self, filepath=None): """ Saves a session to a .io file. """ if filepath is None and self.filepath: filepath = self.filepath if not filepath: raise AbcViewError("File path not set") elif not filepath.endswith(self.EXT): filepath += self.EXT self.filepath = filepath self.date = time.time() log.debug("[%s.save] %s" % (self, filepath)) state = { "app": { "program": self.program, "version": self.version, "module": os.path.dirname(__file__), }, "env": { "user": os.environ.get("USER", os.environ.get("USERNAME")), "host": os.environ.get("HOST", os.environ.get("HOSTNAME")), "platform": sys.platform, }, "date": self.date, "min_time": self.min_time, "max_time": self.max_time, "current_time": self.current_time, "frames_per_second": self.frames_per_second, "properties": self.properties.local, "cameras": [camera.serialize() for camera in self.__cameras.values()], "data": self.serialize() } json.dump(state, open(filepath, "w"), sort_keys=True, indent=4)
def save(self, filepath=None): """ Saves a session to a .io file. """ if filepath is None and self.filepath: filepath = self.filepath if not filepath: raise AbcViewError("File path not set") elif not filepath.endswith(self.EXT): filepath += self.EXT self.filepath = filepath self.date = time.time() log.debug("[%s.save] %s" % (self, filepath)) state = { "app": { "program": self.program, "version": self.version, "module": os.path.dirname(__file__), }, "env": { "user": os.environ.get("USER", os.environ.get("USERNAME")), "host": os.environ.get("HOST", os.environ.get("HOSTNAME")), "platform": sys.platform, }, "date": self.date, "min_time": self.min_time, "max_time": self.max_time, "current_time": self.current_time, "frames_per_second": self.frames_per_second, "properties": self.properties, "cameras": [camera.serialize() for camera in self.__cameras.values()], "data": self.serialize() } json.dump(state, open(filepath, "w"), sort_keys=True, indent=4)