From 0d8dac8ab93a828f0ae5a6897ceb08f88500e59b Mon Sep 17 00:00:00 2001 From: Alexander Hosking Date: Mon, 9 Jan 2023 01:37:34 -0500 Subject: [PATCH] Update env variables --- gmail/email_count.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/gmail/email_count.py b/gmail/email_count.py index ed0b89e..06c88cb 100644 --- a/gmail/email_count.py +++ b/gmail/email_count.py @@ -7,15 +7,12 @@ from influxdb_client.client.write_api import SYNCHRONOUS from dotenv import load_dotenv, dotenv_values load_dotenv() -dotenv_file = os.path.realpath(os.path.dirname(__file__)) + "/.env" -config = dotenv_values(dotenv_file) +# dotenv_file = os.path.realpath(os.path.dirname(__file__)) + "/.env" +# config = dotenv_values(dotenv_file) EMAIL_ACCOUNTS = json.loads(os.environ.get("MAIL_ACCOUNTS")) EMAIL_PASSWORDS = json.loads(os.environ.get("MAIL_PASSWORDS")) -# print() -# print(config['DB_URL']) -# print() # using zip() # to convert lists to dictionary accounts = dict(zip(EMAIL_ACCOUNTS, EMAIL_PASSWORDS)) @@ -23,9 +20,9 @@ accounts = dict(zip(EMAIL_ACCOUNTS, EMAIL_PASSWORDS)) # Influx DB client = influxdb_client.InfluxDBClient( - url=config['DB_URL'], - token=config['DB_TOKEN'], - org=config['DB_ORG'] + url=os.environ.get('DB_URL'), + token=os.environ.get('DB_TOKEN'), + org=os.environ.get('DB_ORG') ) ################ IMAP SSL ############################## @@ -66,8 +63,5 @@ for account in accounts: point = influxdb_client.Point("unread_emails").time(timestamp).tag("account", account)\ .field("count", unread_messages) write_api.write(bucket="personal_data", - org=config['DB_ORG'], record=point) + org=os.environ.get('DB_ORG'), record=point) print(message) - -print( - f"File location using __file__ variable: {os.path.realpath(os.path.dirname(__file__))}")