Skip to content

Commit

Permalink
ad d try/catch when operate personal_conf,bugfix (#799)
Browse files Browse the repository at this point in the history
Co-authored-by: yangfan100 <[email protected]>
  • Loading branch information
echoyang7 and yangfan100 authored Oct 31, 2023
1 parent c10a638 commit 927ba0e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions lyrebird/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,19 @@ def update_personal_config(self, config_dict: dict):
self.write_personal_config()

def read_personal_config(self):
with codecs.open(self.personal_conf_file, 'r', 'utf-8') as f:
return json.load(f)
try:
with codecs.open(self.personal_conf_file, 'r', 'utf-8') as f:
return json.load(f)
except json.JSONDecodeError:
logger.error(f'Failed to parse personal config file {self.personal_conf_file}!')
return personal_config_template

def write_personal_config(self):
with codecs.open(self.personal_conf_file, 'w', 'utf-8') as f:
f.write(json.dumps(self.personal_config, indent=4, ensure_ascii=False))
try:
with codecs.open(self.personal_conf_file, 'w', 'utf-8') as f:
f.write(json.dumps(self.personal_config, indent=4, ensure_ascii=False))
except Exception as e:
logger.error(f'Failed to write personal config: {e}')


class Config:
Expand Down
2 changes: 1 addition & 1 deletion lyrebird/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
IVERSION = (2, 20, 0)
IVERSION = (2, 20, 1)
VERSION = ".".join(str(i) for i in IVERSION)
LYREBIRD = "Lyrebird " + VERSION

0 comments on commit 927ba0e

Please sign in to comment.