Skip to content

Commit

Permalink
take invalid input into account
Browse files Browse the repository at this point in the history
  • Loading branch information
eemilhaa committed May 15, 2022
1 parent 48339b2 commit 7efd381
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ def get_display_size(display_height):
A tuple with the display dimension. The aspect ratio is always 4:3.
"""

try:
display_height = int(display_height)
except ValueError:
display_height = 900
print("invalid display height value in .env, using defaults")

return (
display_height / 0.75,
display_height
Expand All @@ -23,11 +29,11 @@ def get_display_size(display_height):
try:
load_dotenv(dotenv_path=os.path.join(dirname, "..", ".env"))
except FileNotFoundError:
print("no .env file found, using defaults")
pass


DISPLAY_SIZE = get_display_size(
display_height=int(os.getenv("DISPLAY_HEIGHT")) or 900
display_height=os.getenv("DISPLAY_HEIGHT") or 900
)

DATABASE_FILENAME = os.getenv("DATABASE_FILENAME") or "database.db"
Expand Down

0 comments on commit 7efd381

Please sign in to comment.