Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Commit

Permalink
fix: fix error when loading config
Browse files Browse the repository at this point in the history
  • Loading branch information
zyf722 committed Feb 4, 2024
1 parent 8bb24d7 commit f327321
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions examples/bf1chs/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,9 +508,12 @@ def __init__(self) -> None:

# Load config
try:
config_loaded = False
try:
with open("config.json", "r", encoding="utf-8") as f:
self.config = BF1ChsToolbox.Config.load(json.load(f))
config_loaded = True

except BF1ChsToolbox.IncompatibleConfigException:
console.print("[yellow]配置文件 config.json 版本不兼容。\n")
if self._rich_confirm(message="是否尝试升级?"):
Expand All @@ -530,11 +533,14 @@ def __init__(self) -> None:
)

console.print("[bold green]配置文件升级成功。\n")
config_loaded = True

finally:
self.config.show()
self.paratranz_api = ParaTranzAPI(
self.config["paratranz.token"], PROJECT_ID
)
if config_loaded:
self.config.show()
self.paratranz_api = ParaTranzAPI(
self.config["paratranz.token"], PROJECT_ID
)

except FileNotFoundError:
self.config = BF1ChsToolbox.Config()
Expand Down

0 comments on commit f327321

Please sign in to comment.