forked from extern/easydiffusion
get_config: return default value if conf file is corrupted
This commit is contained in:
parent
566cb55f36
commit
0f6caaec33
@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import argparse
|
import argparse
|
||||||
|
import sys
|
||||||
|
|
||||||
# The config file is in the same directory as this script
|
# The config file is in the same directory as this script
|
||||||
config_directory = os.path.dirname(__file__)
|
config_directory = os.path.dirname(__file__)
|
||||||
@ -21,16 +22,16 @@ if os.path.isfile(config_yaml):
|
|||||||
try:
|
try:
|
||||||
config = yaml.safe_load(configfile)
|
config = yaml.safe_load(configfile)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e, file=sys.stderr)
|
||||||
exit()
|
config = {}
|
||||||
elif os.path.isfile(config_json):
|
elif os.path.isfile(config_json):
|
||||||
import json
|
import json
|
||||||
with open(config_json, 'r') as configfile:
|
with open(config_json, 'r') as configfile:
|
||||||
try:
|
try:
|
||||||
config = json.load(configfile)
|
config = json.load(configfile)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e, file=sys.stderr)
|
||||||
exit()
|
config = {}
|
||||||
else:
|
else:
|
||||||
config = {}
|
config = {}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user