-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
34 lines (30 loc) · 908 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from datetime import datetime
from Traffic import Traffic
import logger
import time
import Report
from Cfg import Cfg
#parse the config object from config.ini
config = Cfg("config.ini")
def main():
# always on loop to send mail at hour zero of the day
while True:
if str(datetime.now().strftime("%H:%M")) == "00:00":
#Generate traffic report object and log it remotely with mysql
traffic = Traffic()
#store instance data
down = traffic.get("down")
up = traffic.get("up")
timeStamp = traffic.get("timestamp")
#pass the destination and data to the handler
Report.handler(config, up, down, timeStamp)
#62 to prevent double run
time.sleep(62)
#test to ensure fucntionality on start
def init():
print("starting")
logger.startup_test(config.SMTP_OUTPUT_receivingAddr)
time.sleep(5)
print("check passed, running main")
main()
init()