mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-01-12 17:28:56 +01:00
Merge pull request #1288 from JeLuF/getconfx
get_config: return default value if conf file is corrupted
This commit is contained in:
commit
d4582e9e6e
@ -1,5 +1,6 @@
|
||||
import os
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
# The config file is in the same directory as this script
|
||||
config_directory = os.path.dirname(__file__)
|
||||
@ -21,16 +22,16 @@ if os.path.isfile(config_yaml):
|
||||
try:
|
||||
config = yaml.safe_load(configfile)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
exit()
|
||||
print(e, file=sys.stderr)
|
||||
config = {}
|
||||
elif os.path.isfile(config_json):
|
||||
import json
|
||||
with open(config_json, 'r') as configfile:
|
||||
try:
|
||||
config = json.load(configfile)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
exit()
|
||||
print(e, file=sys.stderr)
|
||||
config = {}
|
||||
else:
|
||||
config = {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user