def reload(self): if self.__always_enable: self.__button['state'] = DGG.NORMAL else: self.__button['state'] = DGG.DISABLED datafile = game_settings[ 'save_folder'] + self.__fileName + game_settings['save_type'] infofile = game_settings[ 'save_folder'] + self.__fileName + game_settings['save_infotype'] if exists(datafile) and exists(infofile): infostream = open( game_settings['save_folder'] + self.__fileName + game_settings['save_infotype'], 'rb') info = pickle.load(infostream) infostream.close() temp = info.text.splitlines() if temp: text = temp[0] else: text = '' if len(text) > 15: text = text[0:13] + '...' self.__text.setText(self.__head + '\n' + info.time.strftime('%Y-%m-%d %H:%M') + '\n' + ' ' + text) self.__button['state'] = DGG.NORMAL self.__exists = True else: self.__text.setText(self.__head + '\n NO DATA') self.__exists = False
def get_bounds(need_reload, key, np): h = sha384(f'{key}-road-{np.name}'.encode()).hexdigest() fname = core.Filename(base.main_dir, f'assets/cache/{h}') if need_reload: bounds = pp.get_model_bounds(np) with open(fname.to_os_specific(), 'wb') as f: pickle.dump(bounds, f) else: with open(fname.to_os_specific(), 'rb') as f: bounds = pickle.load(f) return bounds
def load_data(file_name): _savingloadinglock.acquire() try: f = open(file_name, 'rb') loaded = pickle.load(f) f.close() except Exception as exp: raise exp finally: _savingloadinglock.release() return loaded
def load_data(file_name): _savingloadinglock.acquire() try: f = open(file_name,'rb') loaded = pickle.load(f) f.close() except Exception as exp: raise exp finally: _savingloadinglock.release() return loaded
def reload(self): if self.__always_enable: self.__button['state'] = DGG.NORMAL else: self.__button['state'] = DGG.DISABLED datafile = game_settings['save_folder']+ self.__fileName + game_settings['save_type'] infofile = game_settings['save_folder']+ self.__fileName + game_settings['save_infotype'] if exists(datafile) and exists(infofile): infostream = open(game_settings['save_folder']+ self.__fileName + game_settings['save_infotype'],'rb') info = pickle.load(infostream) infostream.close() temp = info.text.splitlines() if temp: text = temp[0] else: text = '' if len(text)>15: text = text[0:13] + '...' self.__text.setText(self.__head+'\n'+info.time.strftime('%Y-%m-%d %H:%M')+'\n'+' '+text) self.__button['state'] = DGG.NORMAL self.__exists = True else: self.__text.setText(self.__head + '\n NO DATA') self.__exists = False
def loadRuntimeData(saved): '''restore the data from saved runtime data''' global RuntimeData data = pickle.load(saved) RuntimeData.load(data)