From 28318d3abaed8fadf298b5a8443d4dfe3edba104 Mon Sep 17 00:00:00 2001 From: Levi <57452819+l3v11@users.noreply.github.com> Date: Thu, 13 Oct 2022 17:52:30 +0600 Subject: [PATCH] Fix bot crashing when some optional env vars aren't filled up --- bot/__init__.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/bot/__init__.py b/bot/__init__.py index b8b3968e..2cf20bbd 100644 --- a/bot/__init__.py +++ b/bot/__init__.py @@ -80,7 +80,9 @@ else: AUTHORIZED_USERS = set() -DATABASE_URL = os.environ.get('DATABASE_URL', None) +DATABASE_URL = os.environ.get('DATABASE_URL', '') +if len(DATABASE_URL) == 0: + DATABASE_URL = None IS_TEAM_DRIVE = os.environ.get('IS_TEAM_DRIVE', '') IS_TEAM_DRIVE = IS_TEAM_DRIVE.lower() == 'true' @@ -147,10 +149,15 @@ except Exception as err: LOGGER.error(f"DRIVE_LIST_URL: {err}") -APPDRIVE_EMAIL = os.environ.get('APPDRIVE_EMAIL', None) -APPDRIVE_PASS = os.environ.get('APPDRIVE_PASS', None) +APPDRIVE_EMAIL = os.environ.get('APPDRIVE_EMAIL', '') +APPDRIVE_PASS = os.environ.get('APPDRIVE_PASS', '') +if len(APPDRIVE_EMAIL) == 0 or len(APPDRIVE_PASS) == 0: + APPDRIVE_EMAIL = None + APPDRIVE_PASS = None -GDTOT_CRYPT = os.environ.get('GDTOT_CRYPT', None) +GDTOT_CRYPT = os.environ.get('GDTOT_CRYPT', '') +if len(GDTOT_CRYPT) == 0: + GDTOT_CRYPT = None if os.path.exists('drive_list'): with open('drive_list', 'r+') as f: