Added .env file and taking varibles from that .env file
This commit is contained in:
parent
4906291dc2
commit
1ae867c892
4
mailling/localhost/local.env
Normal file
4
mailling/localhost/local.env
Normal file
@ -0,0 +1,4 @@
|
||||
PROJECT_IDS=2618eb89-2823-11f0-9d9e-bc241163f504,08dd9d0d-2ac4-4789-840e-77fa48f55d40,2618f2ef-2823-11f0-9d9e-bc241163f504
|
||||
BASE_URL=http://localhost:5032/api
|
||||
USERNAME=admin@marcoaiot.com
|
||||
PASSWORD=User@123
|
@ -1,6 +1,13 @@
|
||||
import sys
|
||||
import requests
|
||||
from datetime import date, timedelta
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
|
||||
load_dotenv(dotenv_path="local.env")
|
||||
|
||||
project_ids_str = os.getenv("PROJECT_IDS")
|
||||
project_ids = [pid.strip() for pid in project_ids_str.split(",")] if project_ids_str else []
|
||||
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
@ -8,13 +15,12 @@ if len(sys.argv) > 1:
|
||||
else:
|
||||
date = date.today() - timedelta(days=1)
|
||||
|
||||
project_id = "2618eb89-2823-11f0-9d9e-bc241163f504"
|
||||
base_url = "http://localhost:5032/api"
|
||||
base_url = os.getenv("BASE_URL")
|
||||
|
||||
def login():
|
||||
payload = {
|
||||
"username": "admin@marcoaiot.com",
|
||||
"password": "User@123"
|
||||
"username": os.getenv("USERNAME"),
|
||||
"password": os.getenv("PASSWORD")
|
||||
}
|
||||
|
||||
headers = {
|
||||
@ -32,17 +38,19 @@ def project_proccess(jwt,project_id,date):
|
||||
"Authorization": f"Bearer {jwt}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
print(date)
|
||||
response = requests.get(f"{base_url}/report/project-statistics/{project_id}?date={date}", headers=headers)
|
||||
return response.status_code
|
||||
return response
|
||||
|
||||
try:
|
||||
jwt = login()
|
||||
code = project_proccess(jwt,project_id,date)
|
||||
if code == 200:
|
||||
print("Email sent")
|
||||
else:
|
||||
print(f"{code}")
|
||||
for project_id in project_ids:
|
||||
print(project_id)
|
||||
response = project_proccess(jwt, project_id, date) # Call your function
|
||||
|
||||
if response.status_code == 200:
|
||||
print("Email sent")
|
||||
else:
|
||||
print(f"Failed with response: {response}")
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
|
||||
|
@ -1,6 +1,13 @@
|
||||
import sys
|
||||
import requests
|
||||
from datetime import date, timedelta
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
|
||||
load_dotenv(dotenv_path="production.env")
|
||||
|
||||
project_ids_str = os.getenv("PROJECT_IDS")
|
||||
project_ids = [pid.strip() for pid in project_ids_str.split(",")] if project_ids_str else []
|
||||
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
@ -8,13 +15,12 @@ if len(sys.argv) > 1:
|
||||
else:
|
||||
date = date.today() - timedelta(days=1)
|
||||
|
||||
project_id = "2618eb89-2823-11f0-9d9e-bc241163f504"
|
||||
base_url = "https://api.marcoaiot.com/api"
|
||||
base_url = os.getenv("BASE_URL")
|
||||
|
||||
def login():
|
||||
payload = {
|
||||
"username": "admin@marcoaiot.com",
|
||||
"password": "User@123"
|
||||
"username": os.getenv("USERNAME"),
|
||||
"password": os.getenv("PASSWORD")
|
||||
}
|
||||
|
||||
headers = {
|
||||
@ -32,17 +38,19 @@ def project_proccess(jwt,project_id,date):
|
||||
"Authorization": f"Bearer {jwt}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
print(date)
|
||||
response = requests.get(f"{base_url}/report/project-statistics/{project_id}?date={date}", headers=headers)
|
||||
return response.status_code
|
||||
return response
|
||||
|
||||
try:
|
||||
jwt = login()
|
||||
code = project_proccess(jwt,project_id,date)
|
||||
if code == 200:
|
||||
print("Email sent")
|
||||
else:
|
||||
print(f"{code}")
|
||||
for project_id in project_ids:
|
||||
print(project_id)
|
||||
response = project_proccess(jwt, project_id, date) # Call your function
|
||||
|
||||
if response.status_code == 200:
|
||||
print("Email sent")
|
||||
else:
|
||||
print(f"Failed with response: {response}")
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
|
||||
|
4
mailling/prod/production.env
Normal file
4
mailling/prod/production.env
Normal file
@ -0,0 +1,4 @@
|
||||
PROJECT_IDS=2618eb89-2823-11f0-9d9e-bc241163f504,08dd9d0d-2ac4-4789-840e-77fa48f55d40,2618f2ef-2823-11f0-9d9e-bc241163f504
|
||||
BASE_URL=https://api.marcoaiot.com/api
|
||||
USERNAME=admin@marcoaiot.com
|
||||
PASSWORD=User@123
|
4
mailling/stage/stage.env
Normal file
4
mailling/stage/stage.env
Normal file
@ -0,0 +1,4 @@
|
||||
PROJECT_IDS=2618eb89-2823-11f0-9d9e-bc241163f504,08dd9d0d-2ac4-4789-840e-77fa48f55d40,2618f2ef-2823-11f0-9d9e-bc241163f504
|
||||
BASE_URL=https://stageapi.marcoaiot.com/api
|
||||
USERNAME=admin@marcoaiot.com
|
||||
PASSWORD=User@123
|
@ -1,6 +1,14 @@
|
||||
import sys
|
||||
import requests
|
||||
from datetime import date, timedelta
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
import json
|
||||
|
||||
load_dotenv(dotenv_path="stage.env")
|
||||
|
||||
project_ids_str = os.getenv("PROJECT_IDS")
|
||||
project_ids = [pid.strip() for pid in project_ids_str.split(",")] if project_ids_str else []
|
||||
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
@ -8,13 +16,12 @@ if len(sys.argv) > 1:
|
||||
else:
|
||||
date = date.today() - timedelta(days=1)
|
||||
|
||||
project_id = "2618eb89-2823-11f0-9d9e-bc241163f504"
|
||||
base_url = "https://stageapi.marcoaiot.com/api"
|
||||
base_url = os.getenv("BASE_URL")
|
||||
|
||||
def login():
|
||||
payload = {
|
||||
"username": "admin@marcoaiot.com",
|
||||
"password": "User@123"
|
||||
"username": os.getenv("USERNAME"),
|
||||
"password": os.getenv("PASSWORD")
|
||||
}
|
||||
|
||||
headers = {
|
||||
@ -32,17 +39,19 @@ def project_proccess(jwt,project_id,date):
|
||||
"Authorization": f"Bearer {jwt}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
print(date)
|
||||
response = requests.get(f"{base_url}/report/project-statistics/{project_id}?date={date}", headers=headers)
|
||||
return response.status_code
|
||||
return response
|
||||
|
||||
try:
|
||||
jwt = login()
|
||||
code = project_proccess(jwt,project_id,date)
|
||||
if code == 200:
|
||||
print("Email sent")
|
||||
else:
|
||||
print(f"{code}")
|
||||
for project_id in project_ids:
|
||||
print(project_id)
|
||||
response = project_proccess(jwt, project_id, date) # Call your function
|
||||
|
||||
if response.status_code == 200:
|
||||
print("Email sent")
|
||||
else:
|
||||
print(f"Failed with response: {response}")
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user