Catch some ui settings errors

This commit is contained in:
Taylor Helsper 2021-12-03 22:07:07 -06:00
parent d8e7ba7ab0
commit 7f78e26e38

View File

@ -479,13 +479,17 @@ def read_ui_settings():
ui_mynode_file = '/home/bitcoin/.mynode/ui.json'
# read ui.json from HDD
if os.path.isfile(ui_hdd_file):
with open(ui_hdd_file, 'r') as fp:
ui_settings = json.load(fp)
# read ui.json from mynode
elif os.path.isfile(ui_mynode_file):
with open(ui_mynode_file, 'r') as fp:
ui_settings = json.load(fp)
try:
if os.path.isfile(ui_hdd_file):
with open(ui_hdd_file, 'r') as fp:
ui_settings = json.load(fp)
# read ui.json from mynode
elif os.path.isfile(ui_mynode_file):
with open(ui_mynode_file, 'r') as fp:
ui_settings = json.load(fp)
except Exception as e:
# Error reading ui settings
pass
# If no files were read, init variable and mark we need to write files
need_file_write = False
@ -513,12 +517,12 @@ def write_ui_settings(ui_settings_new):
try:
with open(ui_hdd_file, 'w') as fp:
json.dump(ui_settings, fp)
with open(ui_mynode_file, 'w') as fp:
json.dump(ui_settings, fp)
except:
pass
with open(ui_mynode_file, 'w') as fp:
json.dump(ui_settings, fp)
def get_ui_setting(name):
ui_settings = read_ui_settings()
return ui_settings[name]