def read_user_config(path, dormant=False): """Parse and store the user config settings in encompass.conf into user_config[]. dormant: Whether the global active chain should be ignored. """ if not path: return {} # Return a dict, since we will call update() on it. config_path = os.path.join(path, "config") result = {} try: with open(config_path, "r") as f: data = f.read() except IOError: print_msg("Error: Cannot read config file.") result = {} try: result = json.loads(data) except: try: result = ast.literal_eval(data) except: print_msg("Error: Cannot read config file.") return {} if not type(result) is dict: return {} if not dormant: chainparams.set_active_chain(result.get('active_chain_code', 'BTC')) return result
def set_active_chain_code(self, value, save = True): """Easy way to account for the config being divided by chain indices""" value = value.upper() if not chainparams.is_known_chain(value): return False with self.lock: self.user_config['active_chain_code'] = value chainparams.set_active_chain(value) # Make an empty dict if nothing is there if self.user_config.get(value, None) is None: self.user_config[value] = {} if save: self.save_user_config() return True
def set_active_chain_code(self, value, save=True): """Easy way to account for the config being divided by chain indices""" value = value.upper() if not chainparams.is_known_chain(value): return False with self.lock: self.user_config['active_chain_code'] = value chainparams.set_active_chain(value) # Make an empty dict if nothing is there if self.user_config.get(value, None) is None: self.user_config[value] = {} if save: self.save_user_config() return True
def read_user_config(path): """Parse and store the user config settings in encompass.conf into user_config[].""" if not path: return {} # Return a dict, since we will call update() on it. config_path = os.path.join(path, "config") result = {} if os.path.exists(config_path): try: with open(config_path, "r") as f: data = f.read() result = ast.literal_eval( data ) #parse raw data from reading wallet file except Exception: print_msg("Error: Cannot read config file.") result = {} if not type(result) is dict: return {} chainparams.set_active_chain(result.get('active_chain_code', 'BTC')) return result
def read_user_config(path): """Parse and store the user config settings in encompass.conf into user_config[].""" if not path: return {} # Return a dict, since we will call update() on it. config_path = os.path.join(path, "config") result = {} if os.path.exists(config_path): try: with open(config_path, "r") as f: data = f.read() result = ast.literal_eval( data) #parse raw data from reading wallet file except Exception: print_msg("Error: Cannot read config file.") result = {} if not type(result) is dict: return {} chainparams.set_active_chain(result.get('active_chain_code', 'BTC')) return result