Skip to content

Commit

Permalink
fix: account file read error (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
iholston committed Nov 24, 2023
1 parent b5809b4 commit 7fa4c82
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions lolbot/common/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ class AccountManager(AccountGenerator):
"""Class that handles account persistence"""

def __init__(self):
data = {'accounts': []}
self.default_data = {'accounts': []}
if not os.path.exists(Constants.ACCOUNT_PATH):
with open(Constants.ACCOUNT_PATH, 'w+') as f:
json.dump(data, f, indent=4)
else:
with open(Constants.ACCOUNT_PATH, 'w+') as f:
try:
json.load(f)
except:
json.dump(data, f, indent=4)
json.dump(self.default_data, f, indent=4)
try:
with open(Constants.ACCOUNT_PATH, 'r') as f:
json.load(f)
except:
with open(Constants.ACCOUNT_PATH, 'w') as f:
json.dump(self.default_data, f, indent=4)

def get_account(self, max_level: int) -> Account:
"""Gets an account username from JSON file where level is < max_level"""
Expand Down
2 changes: 1 addition & 1 deletion lolbot/view/config_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def create_tab(self, parent: int) -> None:
dpg.add_spacer()
with dpg.group(horizontal=True):
dpg.add_input_text(default_value='League Installation Path', width=180, enabled=False)
dpg.add_input_text(tag="LeaguePath", default_value=self.config.get_data('league_path'), width=380, callback=self._set_dir)
dpg.add_input_text(tag="LeaguePath", default_value=self.config.get_data('league_dir'), width=380, callback=self._set_dir)
with dpg.group(horizontal=True):
dpg.add_input_text(default_value='Game Mode', width=180, readonly=True)
dpg.add_combo(tag="GameMode", items=list(self.lobbies.keys()), default_value=list(self.lobbies.keys())[
Expand Down

0 comments on commit 7fa4c82

Please sign in to comment.