Switch to using dotenv module to retrieve environment variables

This commit is contained in:
moshferatu 2023-12-13 08:58:35 -08:00
parent 7a177b38c9
commit f2b1bb8d2a
3 changed files with 11 additions and 4 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.env

View File

@ -5,7 +5,12 @@ import schedule
import time import time
import zipfile import zipfile
quotes_directory = os.environ['DOWNLOAD_DIRECTORY'] from dotenv import load_dotenv
from os import getenv
load_dotenv()
quotes_directory = getenv('DOWNLOAD_DIRECTORY')
download_directory = quotes_directory + 'Zip Archive/' download_directory = quotes_directory + 'Zip Archive/'
def process_file(file: str): def process_file(file: str):
@ -20,11 +25,11 @@ def download_quotes():
client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect( client.connect(
hostname='sftp.datashop.livevol.com', hostname='sftp.datashop.livevol.com',
username=os.environ['USER'], username=getenv('USER'),
password=os.environ['PASSWORD'] password=getenv('PASSWORD')
) )
sftp = client.open_sftp() sftp = client.open_sftp()
sftp.chdir('./subscriptions/' + os.environ['ORDER'] + '/' + os.environ['ITEM']) sftp.chdir('./subscriptions/' + getenv('ORDER') + '/' + getenv('ITEM'))
files = sftp.listdir() files = sftp.listdir()
for file in files: for file in files:
local_file = download_directory + file local_file = download_directory + file

View File

@ -1,4 +1,5 @@
pandas pandas
paramiko paramiko
python-dotenv
pytz pytz
schedule schedule