def write_file(self, file_path): session_data = json.write(self.ui._freeze()) f = open(file_path, 'w') try: f.write(session_data) finally: f.close()
def write_file(self, file_path): # First make sure the game is showing, as we need that to get the piece positions session_data = json.write(self.ui._freeze()) f = open(file_path, 'w') try: f.write(session_data) finally: f.close()
def request_image_cb (self, sender=None): logger.debug('Sending image to %s', sender) img = self.activity.ui.game.board.cutboard.get_image_as_png() t = time.time() compressed = zlib.compress(img, 9) # We will be sending the image, 24K at a time (my tests put the high water at 48K) logger.debug("was %d, is %d. compressed to %d%% in %0.4f seconds" % (len(img), len(compressed), len(compressed)*100/len(img), time.time() - t)) part_size = 24*1024 parts = len(compressed) / part_size for i in range(parts+1): self.tube.get_object(sender, PATH).ImageSync(compressed[i*part_size:(i+1)*part_size], i+1, dbus_interface=IFACE) self.tube.get_object(sender, PATH).ImageDetailsSync(json.write(self.activity.ui._freeze(journal=False)), dbus_interface=IFACE)
def sync(self, *args): """ reads the current state for the slider_ui and keeps it """ if self._lock: return logger.debug("sync'ing game state") self.frozen = json.write(self.slider_ui._freeze(journal=False))
def sync (self, *args): """ reads the current state for the slider_ui and keeps it """ if self._lock: return logger.debug("sync'ing game state") self.frozen = json.write(self.slider_ui._freeze(journal=False))