Skip to content

Commit

Permalink
Merge pull request #379 from PyBotDevs/autogenerate-settings-db-file
Browse files Browse the repository at this point in the history
Autogenerate `settings.json` config file when performing bot client initial setup
  • Loading branch information
notsniped authored Apr 25, 2024
2 parents ee0d520 + ff28972 commit cc05df2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ logs/currency.log
logs/error-log.txt
logs/info-log.txt
logs/startup-log.txt
config/settings.json
__pycache__
*.bak
venv
1 change: 0 additions & 1 deletion config/settings.json

This file was deleted.

10 changes: 10 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ def initial_setup():
except IOError as e:
logger.error(f"Failed to make database file: {e}", module="main/Setup")

# Generating other files
try:
if not os.path.isfile(f"config/settings.json"):
logger.warn(f"[main/Setup] Settings database file was not found in config directory. Creating new database...", module="main/Setup", nolog=True)
with open(f"config/settings.json", 'x', encoding="utf-8") as f:
json.dump({}, f)
f.close()
except IOError as e:
logger.error(f"Failed to make settings database file: {e}", module="main/Setup")

# Generating client log files
try:
if not os.path.isfile("logs/info-log.txt"):
Expand Down

0 comments on commit cc05df2

Please sign in to comment.