def load_path(self, path): try: with open(path) as file: jdict = json.load(file) except: jdict = dict() traceback.print_exc() jdict = util.recursive_encode(jdict, 'utf-8') self.load_jdict(jdict)
def read_state(): try: with open(STATE_FILE, 'r') as file: return util.recursive_encode(json.load(file), 'utf-8') except IOError as e: if e.errno != 2: raise except: traceback.print_exc() return dict()
def read_prev_hosts(): new_prev_hosts = dict() if os.path.exists(PREV_HOSTS_FILE): try: with open(PREV_HOSTS_FILE) as file: new_prev_hosts = json.load(file) except (ValueError, IOError): traceback.print_exc() new_prev_hosts = util.recursive_encode(new_prev_hosts, 'utf-8') return new_prev_hosts
def get_state(): global global_state if global_state is not None: return global_state global_state = dict() if os.path.exists(STATE_FILE): try: with open(STATE_FILE) as file: global_state = json.load(file) except (ValueError, IOError): traceback.print_exc() global_state = util.recursive_encode(global_state, 'utf-8') return global_state
def get_state(): try: with open(STATE_FILE) as file: return util.recursive_encode(json.load(file), 'utf-8') except (ValueError, IOError): return dict()