Add time to console, reset count at new day

This commit is contained in:
Jxck-S 2020-09-26 20:24:28 -04:00
parent a71e603be7
commit 4eef78c2b5
2 changed files with 17 additions and 2 deletions

View File

@ -5,6 +5,8 @@ import time
from defADSBX import pullADSBX from defADSBX import pullADSBX
from colorama import Fore, Back, Style from colorama import Fore, Back, Style
from planeClass import Plane from planeClass import Plane
from datetime import datetime
import pytz
main_config = configparser.ConfigParser() main_config = configparser.ConfigParser()
main_config.read('mainconf.ini') main_config.read('mainconf.ini')
import os import os
@ -20,10 +22,18 @@ if main_config.get('DATA', 'SOURCE') == "ADSBX":
elif main_config.get('DATA', 'SOURCE') == "OPENS": elif main_config.get('DATA', 'SOURCE') == "OPENS":
raise NotImplementedError raise NotImplementedError
running_Count = 0 running_Count = 0
try:
tz = pytz.timezone(main_config.get('DATA', 'TZ'))
except pytz.exceptions.UnknownTimeZoneError:
tz = pytz.UTC
while True: while True:
datetime_tz = datetime.now(tz)
if datetime_tz.hour == 0 and datetime_tz.minute == 0:
running_Count = 0
running_Count +=1 running_Count +=1
start_time = time.time() start_time = time.time()
print (Back.GREEN, Fore.BLACK, "--------", running_Count, "-------------------------------------------------------", Style.RESET_ALL) print (Back.GREEN, Fore.BLACK, "--------", running_Count, "--------", datetime_tz.strftime("%I:%M:%S %p"), "-------------------------------------------------------", Style.RESET_ALL)
if main_config.get('DATA', 'SOURCE') == "ADSBX": if main_config.get('DATA', 'SOURCE') == "ADSBX":
data, failed = pullADSBX(planes) data, failed = pullADSBX(planes)
if failed == False: if failed == False:
@ -41,7 +51,8 @@ while True:
for obj in planes.values(): for obj in planes.values():
obj.run(None) obj.run(None)
elapsed_calc_time = time.time() - start_time elapsed_calc_time = time.time() - start_time
print (Back.GREEN, Fore.BLACK, "--------", running_Count, "------------------------Elapsed Time-", elapsed_calc_time, " -------------------------------------", Style.RESET_ALL) datetime_tz = datetime.now(tz)
print (Back.GREEN, Fore.BLACK, "--------", running_Count, "--------", datetime_tz.strftime("%I:%M:%S %p"), "------------------------Elapsed Time-", elapsed_calc_time, " -------------------------------------", Style.RESET_ALL)
print(Back.RED, "Sleep 30", Style.RESET_ALL) print(Back.RED, "Sleep 30", Style.RESET_ALL)
time.sleep(30) time.sleep(30)

View File

@ -5,6 +5,10 @@
#ADS-B Exchange has better data but is not avalible unless you feed their network or pay. #ADS-B Exchange has better data but is not avalible unless you feed their network or pay.
SOURCE = ADSBX SOURCE = ADSBX
#Timezone if you want your own time to show in the console, if invalid will be set to UTC.
#List of TZs names https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
TZ = UTC
#ADS-B Exchange https://www.adsbexchange.com/data/ #ADS-B Exchange https://www.adsbexchange.com/data/
[ADSBX] [ADSBX]
API_KEY = apikey API_KEY = apikey