Update env variables
This commit is contained in:
parent
41f0b57275
commit
0d8dac8ab9
@ -7,15 +7,12 @@ from influxdb_client.client.write_api import SYNCHRONOUS
|
|||||||
from dotenv import load_dotenv, dotenv_values
|
from dotenv import load_dotenv, dotenv_values
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
dotenv_file = os.path.realpath(os.path.dirname(__file__)) + "/.env"
|
# dotenv_file = os.path.realpath(os.path.dirname(__file__)) + "/.env"
|
||||||
config = dotenv_values(dotenv_file)
|
# config = dotenv_values(dotenv_file)
|
||||||
|
|
||||||
EMAIL_ACCOUNTS = json.loads(os.environ.get("MAIL_ACCOUNTS"))
|
EMAIL_ACCOUNTS = json.loads(os.environ.get("MAIL_ACCOUNTS"))
|
||||||
EMAIL_PASSWORDS = json.loads(os.environ.get("MAIL_PASSWORDS"))
|
EMAIL_PASSWORDS = json.loads(os.environ.get("MAIL_PASSWORDS"))
|
||||||
|
|
||||||
# print()
|
|
||||||
# print(config['DB_URL'])
|
|
||||||
# print()
|
|
||||||
# using zip()
|
# using zip()
|
||||||
# to convert lists to dictionary
|
# to convert lists to dictionary
|
||||||
accounts = dict(zip(EMAIL_ACCOUNTS, EMAIL_PASSWORDS))
|
accounts = dict(zip(EMAIL_ACCOUNTS, EMAIL_PASSWORDS))
|
||||||
@ -23,9 +20,9 @@ accounts = dict(zip(EMAIL_ACCOUNTS, EMAIL_PASSWORDS))
|
|||||||
|
|
||||||
# Influx DB
|
# Influx DB
|
||||||
client = influxdb_client.InfluxDBClient(
|
client = influxdb_client.InfluxDBClient(
|
||||||
url=config['DB_URL'],
|
url=os.environ.get('DB_URL'),
|
||||||
token=config['DB_TOKEN'],
|
token=os.environ.get('DB_TOKEN'),
|
||||||
org=config['DB_ORG']
|
org=os.environ.get('DB_ORG')
|
||||||
)
|
)
|
||||||
|
|
||||||
################ IMAP SSL ##############################
|
################ IMAP SSL ##############################
|
||||||
@ -66,8 +63,5 @@ for account in accounts:
|
|||||||
point = influxdb_client.Point("unread_emails").time(timestamp).tag("account", account)\
|
point = influxdb_client.Point("unread_emails").time(timestamp).tag("account", account)\
|
||||||
.field("count", unread_messages)
|
.field("count", unread_messages)
|
||||||
write_api.write(bucket="personal_data",
|
write_api.write(bucket="personal_data",
|
||||||
org=config['DB_ORG'], record=point)
|
org=os.environ.get('DB_ORG'), record=point)
|
||||||
print(message)
|
print(message)
|
||||||
|
|
||||||
print(
|
|
||||||
f"File location using __file__ variable: {os.path.realpath(os.path.dirname(__file__))}")
|
|
||||||
|
Loading…
Reference in New Issue
Block a user